mirror of
https://github.com/bitcoin/bitcoin.git
synced 2025-01-10 11:57:28 -03:00
[net] Signal NODE_COMPACT_FILTERS if we're serving compact filters.
If -peerblockfilters is configured, signal the NODE_COMPACT_FILTERS service bit to indicate that we are able to serve compact block filters, headers and checkpoints.
This commit is contained in:
parent
b3fbc94d4f
commit
132b30d9c8
4 changed files with 12 additions and 6 deletions
12
src/init.cpp
12
src/init.cpp
|
@ -996,11 +996,13 @@ bool AppInitParameterInteraction()
|
|||
}
|
||||
}
|
||||
|
||||
// Basic filters are the only supported filters. The basic filters index must be enabled
|
||||
// to serve compact filters
|
||||
if (gArgs.GetBoolArg("-peerblockfilters", DEFAULT_PEERBLOCKFILTERS) &&
|
||||
g_enabled_filter_types.count(BlockFilterType::BASIC) != 1) {
|
||||
return InitError(_("Cannot set -peerblockfilters without -blockfilterindex."));
|
||||
// Signal NODE_COMPACT_FILTERS if peerblockfilters and basic filters index are both enabled.
|
||||
if (gArgs.GetBoolArg("-peerblockfilters", DEFAULT_PEERBLOCKFILTERS)) {
|
||||
if (g_enabled_filter_types.count(BlockFilterType::BASIC) != 1) {
|
||||
return InitError(_("Cannot set -peerblockfilters without -blockfilterindex."));
|
||||
}
|
||||
|
||||
nLocalServices = ServiceFlags(nLocalServices | NODE_COMPACT_FILTERS);
|
||||
}
|
||||
|
||||
// if using block pruning, then disallow txindex
|
||||
|
|
|
@ -2009,7 +2009,7 @@ static bool PrepareBlockFilterRequest(CNode& peer, const CChainParams& chain_par
|
|||
{
|
||||
const bool supported_filter_type =
|
||||
(filter_type == BlockFilterType::BASIC &&
|
||||
gArgs.GetBoolArg("-peerblockfilters", DEFAULT_PEERBLOCKFILTERS));
|
||||
(peer.GetLocalServices() & NODE_COMPACT_FILTERS));
|
||||
if (!supported_filter_type) {
|
||||
LogPrint(BCLog::NET, "peer %d requested unsupported block filter type: %d\n",
|
||||
peer.GetId(), static_cast<uint8_t>(filter_type));
|
||||
|
|
|
@ -213,6 +213,7 @@ static std::string serviceFlagToStr(size_t bit)
|
|||
case NODE_GETUTXO: return "GETUTXO";
|
||||
case NODE_BLOOM: return "BLOOM";
|
||||
case NODE_WITNESS: return "WITNESS";
|
||||
case NODE_COMPACT_FILTERS: return "COMPACT_FILTERS";
|
||||
case NODE_NETWORK_LIMITED: return "NETWORK_LIMITED";
|
||||
// Not using default, so we get warned when a case is missing
|
||||
}
|
||||
|
|
|
@ -285,6 +285,9 @@ enum ServiceFlags : uint64_t {
|
|||
// NODE_WITNESS indicates that a node can be asked for blocks and transactions including
|
||||
// witness data.
|
||||
NODE_WITNESS = (1 << 3),
|
||||
// NODE_COMPACT_FILTERS means the node will service basic block filter requests.
|
||||
// See BIP157 and BIP158 for details on how this is implemented.
|
||||
NODE_COMPACT_FILTERS = (1 << 6),
|
||||
// NODE_NETWORK_LIMITED means the same as NODE_NETWORK with the limitation of only
|
||||
// serving the last 288 (2 day) blocks
|
||||
// See BIP159 for details on how this is implemented.
|
||||
|
|
Loading…
Reference in a new issue