aboutsummaryrefslogtreecommitdiff
path: root/src/node
diff options
context:
space:
mode:
authorSebastian Falbesoner <sebastian.falbesoner@gmail.com>2022-08-23 16:10:59 +0200
committerSebastian Falbesoner <sebastian.falbesoner@gmail.com>2022-10-25 15:57:28 +0200
commit088e38d3bbea9694b319bc34e0d2e70d210c38b4 (patch)
tree526394755d33b599c6ee1e1e7a200ab8ace56755 /src/node
parente7a0e9627196655be5aa6c2738d4b57646a03726 (diff)
downloadbitcoin-088e38d3bbea9694b319bc34e0d2e70d210c38b4.tar.xz
add chain interface methods for using BIP 157 block filters
This is useful for speeding up wallet rescans and is based on an earlier version from PR #15845 ("wallet: Fast rescan with BIP157 block filters"), which was never merged. Co-authored-by: MacroFake <falke.marco@gmail.com>
Diffstat (limited to 'src/node')
-rw-r--r--src/node/interfaces.cpp16
1 files changed, 16 insertions, 0 deletions
diff --git a/src/node/interfaces.cpp b/src/node/interfaces.cpp
index 8a0011a629..979c625463 100644
--- a/src/node/interfaces.cpp
+++ b/src/node/interfaces.cpp
@@ -4,10 +4,12 @@
#include <addrdb.h>
#include <banman.h>
+#include <blockfilter.h>
#include <chain.h>
#include <chainparams.h>
#include <deploymentstatus.h>
#include <external_signer.h>
+#include <index/blockfilterindex.h>
#include <init.h>
#include <interfaces/chain.h>
#include <interfaces/handler.h>
@@ -536,6 +538,20 @@ public:
}
return std::nullopt;
}
+ bool hasBlockFilterIndex(BlockFilterType filter_type) override
+ {
+ return GetBlockFilterIndex(filter_type) != nullptr;
+ }
+ std::optional<bool> blockFilterMatchesAny(BlockFilterType filter_type, const uint256& block_hash, const GCSFilter::ElementSet& filter_set) override
+ {
+ const BlockFilterIndex* block_filter_index{GetBlockFilterIndex(filter_type)};
+ if (!block_filter_index) return std::nullopt;
+
+ BlockFilter filter;
+ const CBlockIndex* index{WITH_LOCK(::cs_main, return chainman().m_blockman.LookupBlockIndex(block_hash))};
+ if (index == nullptr || !block_filter_index->LookupFilter(index, filter)) return std::nullopt;
+ return filter.GetFilter().MatchAny(filter_set);
+ }
bool findBlock(const uint256& hash, const FoundBlock& block) override
{
WAIT_LOCK(cs_main, lock);