Line data Source code
1 : // Copyright (c) 2019-2021 The Bitcoin Core developers 2 : // Distributed under the MIT software license, see the accompanying 3 : // file COPYING or http://www.opensource.org/licenses/mit-license.php. 4 : 5 : #include <test/util/blockfilter.h> 6 : 7 : #include <chainparams.h> 8 : #include <node/blockstorage.h> 9 : #include <validation.h> 10 : 11 : using node::ReadBlockFromDisk; 12 : using node::UndoReadFromDisk; 13 : 14 114 : bool ComputeFilter(BlockFilterType filter_type, const CBlockIndex* block_index, BlockFilter& filter) 15 : { 16 114 : LOCK(::cs_main); 17 : 18 114 : CBlock block; 19 114 : if (!ReadBlockFromDisk(block, block_index->GetBlockPos(), Params().GetConsensus())) { 20 0 : return false; 21 : } 22 : 23 114 : CBlockUndo block_undo; 24 114 : if (block_index->nHeight > 0 && !UndoReadFromDisk(block_undo, block_index)) { 25 0 : return false; 26 : } 27 : 28 114 : filter = BlockFilter(filter_type, block, block_undo); 29 114 : return true; 30 114 : }