Introduce a service flag for CBFs.

Add a service flag for CBFs in the wire protocol.
This commit is contained in:
pedro martelletto 2016-12-13 09:34:25 +00:00 committed by Olaoluwa Osuntokun
parent 1432d294a5
commit d82e76cec9
2 changed files with 9 additions and 0 deletions

View file

@ -10,6 +10,7 @@ import (
"strings" "strings"
) )
// XXX pedro: we will probably need to bump this.
const ( const (
// ProtocolVersion is the latest protocol version this package supports. // ProtocolVersion is the latest protocol version this package supports.
ProtocolVersion uint32 = 70013 ProtocolVersion uint32 = 70013
@ -70,6 +71,10 @@ const (
// SFNodeWitness is a flag used to indicate a peer supports blocks // SFNodeWitness is a flag used to indicate a peer supports blocks
// and transactions including witness data (BIP0144). // and transactions including witness data (BIP0144).
SFNodeWitness SFNodeWitness
// SFNNodeCBF is a flag used to indicate a peer supports committed
// bloom filters (CBFs).
SFNodeCBF
) )
// Map of service flags back to their constant names for pretty printing. // Map of service flags back to their constant names for pretty printing.
@ -78,6 +83,7 @@ var sfStrings = map[ServiceFlag]string{
SFNodeGetUTXO: "SFNodeGetUTXO", SFNodeGetUTXO: "SFNodeGetUTXO",
SFNodeBloom: "SFNodeBloom", SFNodeBloom: "SFNodeBloom",
SFNodeWitness: "SFNodeWitness", SFNodeWitness: "SFNodeWitness",
SFNodeCBF: "SFNodeCBF",
} }
// orderedSFStrings is an ordered list of service flags from highest to // orderedSFStrings is an ordered list of service flags from highest to
@ -87,6 +93,7 @@ var orderedSFStrings = []ServiceFlag{
SFNodeGetUTXO, SFNodeGetUTXO,
SFNodeBloom, SFNodeBloom,
SFNodeWitness, SFNodeWitness,
SFNodeCBF,
} }
// String returns the ServiceFlag in human-readable form. // String returns the ServiceFlag in human-readable form.

View file

@ -18,6 +18,8 @@ func TestServiceFlagStringer(t *testing.T) {
{SFNodeBloom, "SFNodeBloom"}, {SFNodeBloom, "SFNodeBloom"},
{SFNodeWitness, "SFNodeWitness"}, {SFNodeWitness, "SFNodeWitness"},
{0xffffffff, "SFNodeNetwork|SFNodeGetUTXO|SFNodeBloom|SFNodeWitness|0xfffffff0"}, {0xffffffff, "SFNodeNetwork|SFNodeGetUTXO|SFNodeBloom|SFNodeWitness|0xfffffff0"},
{SFNodeCBF, "SFNodeCBF"},
{0xffffffff, "SFNodeNetwork|SFNodeGetUTXO|SFNodeBloom|SFNodeCBF|0xfffffff0"},
} }
t.Logf("Running %d tests", len(tests)) t.Logf("Running %d tests", len(tests))