Skip to content

Commit

Permalink
wire, main: Add SFNodeNetworkLimited flag
Browse files Browse the repository at this point in the history
This change is part of the effort to add pruning support to btcd.

Wire now supports the ability to signal NODE_NETWORK_LIMITED which
signals to peers that the node is able to serve the last 288 blocks.

Since archival nodes have all blocks, they can also signal for
NODE_NETWORK_LIMITED.  SFNodeNetworkLimited flag is added to the default
services.
  • Loading branch information
kcalvinalvin committed Aug 22, 2023
1 parent 57ec43f commit 0212c33
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 11 deletions.
4 changes: 2 additions & 2 deletions server.go
Original file line number Diff line number Diff line change
Expand Up @@ -44,8 +44,8 @@ import (
const (
// defaultServices describes the default services that are supported by
// the server.
defaultServices = wire.SFNodeNetwork | wire.SFNodeBloom |
wire.SFNodeWitness | wire.SFNodeCF
defaultServices = wire.SFNodeNetwork | wire.SFNodeNetworkLimited |
wire.SFNodeBloom | wire.SFNodeWitness | wire.SFNodeCF

// defaultRequiredServices describes the default services that are
// required to be supported by outbound peers.
Expand Down
22 changes: 14 additions & 8 deletions wire/protocol.go
Original file line number Diff line number Diff line change
Expand Up @@ -93,18 +93,23 @@ const (
// SFNode2X is a flag used to indicate a peer is running the Segwit2X
// software.
SFNode2X

// SFNodeNetWorkLimited is a flag used to indicate a peer supports serving
// the last 288 blocks.
SFNodeNetworkLimited = 1 << 10
)

// Map of service flags back to their constant names for pretty printing.
var sfStrings = map[ServiceFlag]string{
SFNodeNetwork: "SFNodeNetwork",
SFNodeGetUTXO: "SFNodeGetUTXO",
SFNodeBloom: "SFNodeBloom",
SFNodeWitness: "SFNodeWitness",
SFNodeXthin: "SFNodeXthin",
SFNodeBit5: "SFNodeBit5",
SFNodeCF: "SFNodeCF",
SFNode2X: "SFNode2X",
SFNodeNetwork: "SFNodeNetwork",
SFNodeGetUTXO: "SFNodeGetUTXO",
SFNodeBloom: "SFNodeBloom",
SFNodeWitness: "SFNodeWitness",
SFNodeXthin: "SFNodeXthin",
SFNodeBit5: "SFNodeBit5",
SFNodeCF: "SFNodeCF",
SFNode2X: "SFNode2X",
SFNodeNetworkLimited: "SFNodeNetworkLimited",
}

// orderedSFStrings is an ordered list of service flags from highest to
Expand All @@ -118,6 +123,7 @@ var orderedSFStrings = []ServiceFlag{
SFNodeBit5,
SFNodeCF,
SFNode2X,
SFNodeNetworkLimited,
}

// String returns the ServiceFlag in human-readable form.
Expand Down
3 changes: 2 additions & 1 deletion wire/protocol_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,8 @@ func TestServiceFlagStringer(t *testing.T) {
{SFNodeBit5, "SFNodeBit5"},
{SFNodeCF, "SFNodeCF"},
{SFNode2X, "SFNode2X"},
{0xffffffff, "SFNodeNetwork|SFNodeGetUTXO|SFNodeBloom|SFNodeWitness|SFNodeXthin|SFNodeBit5|SFNodeCF|SFNode2X|0xffffff00"},
{SFNodeNetworkLimited, "SFNodeNetworkLimited"},
{0xffffffff, "SFNodeNetwork|SFNodeGetUTXO|SFNodeBloom|SFNodeWitness|SFNodeXthin|SFNodeBit5|SFNodeCF|SFNode2X|SFNodeNetworkLimited|0xfffffb00"},
}

t.Logf("Running %d tests", len(tests))
Expand Down

0 comments on commit 0212c33

Please sign in to comment.