aboutsummaryrefslogtreecommitdiff
path: root/src/test/util/blockfilter.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/test/util/blockfilter.cpp')
-rw-r--r--src/test/util/blockfilter.cpp26
1 files changed, 26 insertions, 0 deletions
diff --git a/src/test/util/blockfilter.cpp b/src/test/util/blockfilter.cpp
new file mode 100644
index 0000000000..bccff5e5a6
--- /dev/null
+++ b/src/test/util/blockfilter.cpp
@@ -0,0 +1,26 @@
+// Copyright (c) 2019 The Bitcoin Core developers
+// Distributed under the MIT software license, see the accompanying
+// file COPYING or http://www.opensource.org/licenses/mit-license.php.
+
+#include <test/util/blockfilter.h>
+
+#include <chainparams.h>
+#include <validation.h>
+
+
+bool ComputeFilter(BlockFilterType filter_type, const CBlockIndex* block_index, BlockFilter& filter)
+{
+ CBlock block;
+ if (!ReadBlockFromDisk(block, block_index->GetBlockPos(), Params().GetConsensus())) {
+ return false;
+ }
+
+ CBlockUndo block_undo;
+ if (block_index->nHeight > 0 && !UndoReadFromDisk(block_undo, block_index)) {
+ return false;
+ }
+
+ filter = BlockFilter(filter_type, block, block_undo);
+ return true;
+}
+