mirror of
https://github.com/btcsuite/btcd.git
synced 2025-03-13 11:35:52 +01:00
wire, main: Add SFNodeNetworkLimited flag
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.
This commit is contained in:
parent
57ec43fedc
commit
0212c334ce
3 changed files with 18 additions and 11 deletions
|
@ -44,8 +44,8 @@ import (
|
||||||
const (
|
const (
|
||||||
// defaultServices describes the default services that are supported by
|
// defaultServices describes the default services that are supported by
|
||||||
// the server.
|
// the server.
|
||||||
defaultServices = wire.SFNodeNetwork | wire.SFNodeBloom |
|
defaultServices = wire.SFNodeNetwork | wire.SFNodeNetworkLimited |
|
||||||
wire.SFNodeWitness | wire.SFNodeCF
|
wire.SFNodeBloom | wire.SFNodeWitness | wire.SFNodeCF
|
||||||
|
|
||||||
// defaultRequiredServices describes the default services that are
|
// defaultRequiredServices describes the default services that are
|
||||||
// required to be supported by outbound peers.
|
// required to be supported by outbound peers.
|
||||||
|
|
|
@ -93,18 +93,23 @@ const (
|
||||||
// SFNode2X is a flag used to indicate a peer is running the Segwit2X
|
// SFNode2X is a flag used to indicate a peer is running the Segwit2X
|
||||||
// software.
|
// software.
|
||||||
SFNode2X
|
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.
|
// Map of service flags back to their constant names for pretty printing.
|
||||||
var sfStrings = map[ServiceFlag]string{
|
var sfStrings = map[ServiceFlag]string{
|
||||||
SFNodeNetwork: "SFNodeNetwork",
|
SFNodeNetwork: "SFNodeNetwork",
|
||||||
SFNodeGetUTXO: "SFNodeGetUTXO",
|
SFNodeGetUTXO: "SFNodeGetUTXO",
|
||||||
SFNodeBloom: "SFNodeBloom",
|
SFNodeBloom: "SFNodeBloom",
|
||||||
SFNodeWitness: "SFNodeWitness",
|
SFNodeWitness: "SFNodeWitness",
|
||||||
SFNodeXthin: "SFNodeXthin",
|
SFNodeXthin: "SFNodeXthin",
|
||||||
SFNodeBit5: "SFNodeBit5",
|
SFNodeBit5: "SFNodeBit5",
|
||||||
SFNodeCF: "SFNodeCF",
|
SFNodeCF: "SFNodeCF",
|
||||||
SFNode2X: "SFNode2X",
|
SFNode2X: "SFNode2X",
|
||||||
|
SFNodeNetworkLimited: "SFNodeNetworkLimited",
|
||||||
}
|
}
|
||||||
|
|
||||||
// orderedSFStrings is an ordered list of service flags from highest to
|
// orderedSFStrings is an ordered list of service flags from highest to
|
||||||
|
@ -118,6 +123,7 @@ var orderedSFStrings = []ServiceFlag{
|
||||||
SFNodeBit5,
|
SFNodeBit5,
|
||||||
SFNodeCF,
|
SFNodeCF,
|
||||||
SFNode2X,
|
SFNode2X,
|
||||||
|
SFNodeNetworkLimited,
|
||||||
}
|
}
|
||||||
|
|
||||||
// String returns the ServiceFlag in human-readable form.
|
// String returns the ServiceFlag in human-readable form.
|
||||||
|
|
|
@ -21,7 +21,8 @@ func TestServiceFlagStringer(t *testing.T) {
|
||||||
{SFNodeBit5, "SFNodeBit5"},
|
{SFNodeBit5, "SFNodeBit5"},
|
||||||
{SFNodeCF, "SFNodeCF"},
|
{SFNodeCF, "SFNodeCF"},
|
||||||
{SFNode2X, "SFNode2X"},
|
{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))
|
t.Logf("Running %d tests", len(tests))
|
||||||
|
|
Loading…
Add table
Reference in a new issue