File tree Expand file tree Collapse file tree 2 files changed +24
-0
lines changed Expand file tree Collapse file tree 2 files changed +24
-0
lines changed Original file line number Diff line number Diff line change 5
5
#ifndef BITCOIN_INTERFACES_CHAIN_H
6
6
#define BITCOIN_INTERFACES_CHAIN_H
7
7
8
+ #include < blockfilter.h>
8
9
#include < primitives/transaction.h> // For CTransactionRef
9
10
#include < util/settings.h> // For util::SettingsValue
10
11
@@ -143,6 +144,13 @@ class Chain
143
144
// ! or one of its ancestors.
144
145
virtual std::optional<int > findLocatorFork (const CBlockLocator& locator) = 0;
145
146
147
+ // ! Returns whether a block filter index is available.
148
+ virtual bool hasBlockFilterIndex (BlockFilterType filter_type) = 0;
149
+
150
+ // ! Returns whether any of the elements match the block via a BIP 157 block filter
151
+ // ! or std::nullopt if the block filter for this block couldn't be found.
152
+ virtual std::optional<bool > blockFilterMatchesAny (BlockFilterType filter_type, const uint256& block_hash, const GCSFilter::ElementSet& filter_set) = 0;
153
+
146
154
// ! Return whether node has the block and optionally return block metadata
147
155
// ! or contents.
148
156
virtual bool findBlock (const uint256& hash, const FoundBlock& block={}) = 0;
Original file line number Diff line number Diff line change 4
4
5
5
#include < addrdb.h>
6
6
#include < banman.h>
7
+ #include < blockfilter.h>
7
8
#include < chain.h>
8
9
#include < chainparams.h>
9
10
#include < deploymentstatus.h>
10
11
#include < external_signer.h>
12
+ #include < index/blockfilterindex.h>
11
13
#include < init.h>
12
14
#include < interfaces/chain.h>
13
15
#include < interfaces/handler.h>
@@ -536,6 +538,20 @@ class ChainImpl : public Chain
536
538
}
537
539
return std::nullopt;
538
540
}
541
+ bool hasBlockFilterIndex (BlockFilterType filter_type) override
542
+ {
543
+ return GetBlockFilterIndex (filter_type) != nullptr ;
544
+ }
545
+ std::optional<bool > blockFilterMatchesAny (BlockFilterType filter_type, const uint256& block_hash, const GCSFilter::ElementSet& filter_set) override
546
+ {
547
+ const BlockFilterIndex* block_filter_index{GetBlockFilterIndex (filter_type)};
548
+ if (!block_filter_index) return std::nullopt;
549
+
550
+ BlockFilter filter;
551
+ const CBlockIndex* index{WITH_LOCK (::cs_main, return chainman ().m_blockman .LookupBlockIndex (block_hash))};
552
+ if (index == nullptr || !block_filter_index->LookupFilter (index, filter)) return std::nullopt;
553
+ return filter.GetFilter ().MatchAny (filter_set);
554
+ }
539
555
bool findBlock (const uint256& hash, const FoundBlock& block) override
540
556
{
541
557
WAIT_LOCK (cs_main, lock);
You can’t perform that action at this time.
0 commit comments