Bitcoin Core
28.99.0
P2P Digital Currency
src
test
util
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
5
#include <
test/util/blockfilter.h
>
6
7
#include <chainparams.h>
8
#include <
node/blockstorage.h
>
9
#include <
primitives/block.h
>
10
#include <
undo.h
>
11
#include <
validation.h
>
12
13
using
node::BlockManager
;
14
15
bool
ComputeFilter
(
BlockFilterType
filter_type,
const
CBlockIndex
& block_index,
BlockFilter
& filter,
const
BlockManager
& blockman)
16
{
17
LOCK
(
::cs_main
);
18
19
CBlock
block;
20
if
(!blockman.
ReadBlockFromDisk
(block, block_index.
GetBlockPos
())) {
21
return
false
;
22
}
23
24
CBlockUndo
block_undo;
25
if
(block_index.
nHeight
> 0 && !blockman.
UndoReadFromDisk
(block_undo, block_index)) {
26
return
false
;
27
}
28
29
filter =
BlockFilter
(filter_type, block, block_undo);
30
return
true
;
31
}
block.h
BlockFilterType
BlockFilterType
Definition:
blockfilter.h:93
blockstorage.h
BlockFilter
Complete block filter struct as defined in BIP 157.
Definition:
blockfilter.h:115
CBlock
Definition:
block.h:69
CBlockIndex
The block chain is a tree shaped structure starting with the genesis block at the root,...
Definition:
chain.h:141
CBlockIndex::nHeight
int nHeight
height of the entry in the chain. The genesis block has height 0
Definition:
chain.h:153
CBlockIndex::GetBlockPos
FlatFilePos GetBlockPos() const EXCLUSIVE_LOCKS_REQUIRED(
Definition:
chain.h:208
CBlockUndo
Undo information for a CBlock.
Definition:
undo.h:63
node::BlockManager
Maintains a tree of blocks (stored in m_block_index) which is consulted to determine where the most-w...
Definition:
blockstorage.h:136
node::BlockManager::ReadBlockFromDisk
bool ReadBlockFromDisk(CBlock &block, const FlatFilePos &pos) const
Functions for disk access for blocks.
Definition:
blockstorage.cpp:1029
node::BlockManager::UndoReadFromDisk
bool UndoReadFromDisk(CBlockUndo &blockundo, const CBlockIndex &index) const
Definition:
blockstorage.cpp:699
cs_main
RecursiveMutex cs_main
Mutex to guard access to validation specific variables, such as reading or changing the chainstate.
Definition:
cs_main.cpp:8
LOCK
#define LOCK(cs)
Definition:
sync.h:257
ComputeFilter
bool ComputeFilter(BlockFilterType filter_type, const CBlockIndex &block_index, BlockFilter &filter, const BlockManager &blockman)
Definition:
blockfilter.cpp:15
blockfilter.h
undo.h
validation.h
Generated on Wed Dec 18 2024 20:00:13 for Bitcoin Core by
1.9.4