Bitcoin Core  24.99.0
P2P Digital Currency
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
7 #include <chainparams.h>
8 #include <node/blockstorage.h>
9 #include <validation.h>
14 bool ComputeFilter(BlockFilterType filter_type, const CBlockIndex* block_index, BlockFilter& filter)
15 {
16  LOCK(::cs_main);
18  CBlock block;
19  if (!ReadBlockFromDisk(block, block_index->GetBlockPos(), Params().GetConsensus())) {
20  return false;
21  }
23  CBlockUndo block_undo;
24  if (block_index->nHeight > 0 && !UndoReadFromDisk(block_undo, block_index)) {
25  return false;
26  }
28  filter = BlockFilter(filter_type, block, block_undo);
29  return true;
30 }
Definition: blockfilter.h:90
const CChainParams & Params()
Return the currently selected parameters.
Complete block filter struct as defined in BIP 157.
Definition: blockfilter.h:112
Definition: block.h:69
The block chain is a tree shaped structure starting with the genesis block at the root,...
Definition: chain.h:151
int nHeight
height of the entry in the chain. The genesis block has height 0
Definition: chain.h:163
FlatFilePos GetBlockPos() const EXCLUSIVE_LOCKS_REQUIRED(
Definition: chain.h:224
Undo information for a CBlock.
Definition: undo.h:64
RecursiveMutex cs_main
Mutex to guard access to validation specific variables, such as reading or changing the chainstate.
Definition: cs_main.cpp:7
bool ReadBlockFromDisk(CBlock &block, const FlatFilePos &pos, const Consensus::Params &consensusParams)
Functions for disk access for blocks.
bool UndoReadFromDisk(CBlockUndo &blockundo, const CBlockIndex *pindex)
#define LOCK(cs)
Definition: sync.h:258
bool ComputeFilter(BlockFilterType filter_type, const CBlockIndex *block_index, BlockFilter &filter)
Definition: blockfilter.cpp:14