Bitcoin Core  22.99.0
P2P Digital Currency
blockfilter.cpp
Go to the documentation of this file.
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 
6 
7 #include <chainparams.h>
8 #include <node/blockstorage.h>
9 #include <validation.h>
10 
13 
14 bool ComputeFilter(BlockFilterType filter_type, const CBlockIndex* block_index, BlockFilter& filter)
15 {
16  CBlock block;
17  if (!ReadBlockFromDisk(block, block_index->GetBlockPos(), Params().GetConsensus())) {
18  return false;
19  }
20 
21  CBlockUndo block_undo;
22  if (block_index->nHeight > 0 && !UndoReadFromDisk(block_undo, block_index)) {
23  return false;
24  }
25 
26  filter = BlockFilter(filter_type, block, block_undo);
27  return true;
28 }
29 
ComputeFilter
bool ComputeFilter(BlockFilterType filter_type, const CBlockIndex *block_index, BlockFilter &filter)
Definition: blockfilter.cpp:14
CBlockIndex::nHeight
int nHeight
height of the entry in the chain. The genesis block has height 0
Definition: chain.h:161
chainparams.h
node::ReadBlockFromDisk
bool ReadBlockFromDisk(CBlock &block, const FlatFilePos &pos, const Consensus::Params &consensusParams)
Functions for disk access for blocks.
Definition: blockstorage.cpp:742
CBlockIndex::GetBlockPos
FlatFilePos GetBlockPos() const
Definition: chain.h:226
validation.h
node::UndoReadFromDisk
bool UndoReadFromDisk(CBlockUndo &blockundo, const CBlockIndex *pindex)
Definition: blockstorage.cpp:514
blockfilter.h
CBlock
Definition: block.h:62
blockstorage.h
Params
const CChainParams & Params()
Return the currently selected parameters.
Definition: chainparams.cpp:561
BlockFilterType
BlockFilterType
Definition: blockfilter.h:88
CBlockIndex
The block chain is a tree shaped structure starting with the genesis block at the root,...
Definition: chain.h:148
CBlockUndo
Undo information for a CBlock.
Definition: undo.h:63
BlockFilter
Complete block filter struct as defined in BIP 157.
Definition: blockfilter.h:110