Skip to content

Commit 132b30d

Browse files
jimpojnewbery
authored andcommitted
[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.
1 parent b3fbc94 commit 132b30d

File tree

4 files changed

+12
-6
lines changed

4 files changed

+12
-6
lines changed

src/init.cpp

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -996,11 +996,13 @@ bool AppInitParameterInteraction()
996996
}
997997
}
998998

999-
// Basic filters are the only supported filters. The basic filters index must be enabled
1000-
// to serve compact filters
1001-
if (gArgs.GetBoolArg("-peerblockfilters", DEFAULT_PEERBLOCKFILTERS) &&
1002-
g_enabled_filter_types.count(BlockFilterType::BASIC) != 1) {
1003-
return InitError(_("Cannot set -peerblockfilters without -blockfilterindex."));
999+
// Signal NODE_COMPACT_FILTERS if peerblockfilters and basic filters index are both enabled.
1000+
if (gArgs.GetBoolArg("-peerblockfilters", DEFAULT_PEERBLOCKFILTERS)) {
1001+
if (g_enabled_filter_types.count(BlockFilterType::BASIC) != 1) {
1002+
return InitError(_("Cannot set -peerblockfilters without -blockfilterindex."));
1003+
}
1004+
1005+
nLocalServices = ServiceFlags(nLocalServices | NODE_COMPACT_FILTERS);
10041006
}
10051007

10061008
// if using block pruning, then disallow txindex

src/net_processing.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2009,7 +2009,7 @@ static bool PrepareBlockFilterRequest(CNode& peer, const CChainParams& chain_par
20092009
{
20102010
const bool supported_filter_type =
20112011
(filter_type == BlockFilterType::BASIC &&
2012-
gArgs.GetBoolArg("-peerblockfilters", DEFAULT_PEERBLOCKFILTERS));
2012+
(peer.GetLocalServices() & NODE_COMPACT_FILTERS));
20132013
if (!supported_filter_type) {
20142014
LogPrint(BCLog::NET, "peer %d requested unsupported block filter type: %d\n",
20152015
peer.GetId(), static_cast<uint8_t>(filter_type));

src/protocol.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -213,6 +213,7 @@ static std::string serviceFlagToStr(size_t bit)
213213
case NODE_GETUTXO: return "GETUTXO";
214214
case NODE_BLOOM: return "BLOOM";
215215
case NODE_WITNESS: return "WITNESS";
216+
case NODE_COMPACT_FILTERS: return "COMPACT_FILTERS";
216217
case NODE_NETWORK_LIMITED: return "NETWORK_LIMITED";
217218
// Not using default, so we get warned when a case is missing
218219
}

src/protocol.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -285,6 +285,9 @@ enum ServiceFlags : uint64_t {
285285
// NODE_WITNESS indicates that a node can be asked for blocks and transactions including
286286
// witness data.
287287
NODE_WITNESS = (1 << 3),
288+
// NODE_COMPACT_FILTERS means the node will service basic block filter requests.
289+
// See BIP157 and BIP158 for details on how this is implemented.
290+
NODE_COMPACT_FILTERS = (1 << 6),
288291
// NODE_NETWORK_LIMITED means the same as NODE_NETWORK with the limitation of only
289292
// serving the last 288 (2 day) blocks
290293
// See BIP159 for details on how this is implemented.

0 commit comments

Comments
 (0)