Bitcoin ABC 0.26.3
P2P Digital Currency
|
#include <common/args.h>
#include <dbwrapper.h>
#include <index/blockfilterindex.h>
#include <node/blockstorage.h>
#include <primitives/blockhash.h>
#include <util/fs_helpers.h>
#include <validation.h>
#include <map>
Go to the source code of this file.
Variables | |
constexpr uint8_t | DB_BLOCK_HASH {'s'} |
The index database stores three items for each block: the disk location of the encoded filter, its dSHA256 hash, and the header. | |
constexpr uint8_t | DB_BLOCK_HEIGHT {'t'} |
constexpr uint8_t | DB_FILTER_POS {'P'} |
constexpr unsigned int | MAX_FLTR_FILE_SIZE = 0x1000000 |
constexpr unsigned int | FLTR_FILE_CHUNK_SIZE = 0x100000 |
The pre-allocation chunk size for fltr?????.dat files. | |
constexpr size_t | CF_HEADERS_CACHE_MAX_SZ {2000} |
Maximum size of the cfheaders cache. | |
static std::map< BlockFilterType, BlockFilterIndex > | g_filter_indexes |
|
static |
Definition at line 279 of file blockfilterindex.cpp.
void DestroyAllBlockFilterIndexes | ( | ) |
Destroy all open block filter indexes.
Definition at line 510 of file blockfilterindex.cpp.
bool DestroyBlockFilterIndex | ( | BlockFilterType | filter_type | ) |
Destroy the block filter index with the given type.
Returns false if no such index exists. This just releases the allocated memory and closes the database connection, it does not delete the index data.
Definition at line 506 of file blockfilterindex.cpp.
void ForEachBlockFilterIndex | ( | std::function< void(BlockFilterIndex &)> | fn | ) |
Iterate over all running block filter indexes, invoking fn on each.
Definition at line 492 of file blockfilterindex.cpp.
BlockFilterIndex * GetBlockFilterIndex | ( | BlockFilterType | filter_type | ) |
Get a block filter index by type.
Returns nullptr if index has not been initialized or was already destroyed.
Definition at line 487 of file blockfilterindex.cpp.
bool InitBlockFilterIndex | ( | BlockFilterType | filter_type, |
size_t | n_cache_size, | ||
bool | f_memory = false , |
||
bool | f_wipe = false |
||
) |
Initialize a block filter index for the given type if one does not already exist.
Returns true if a new index is created and false if one has already been initialized.
Definition at line 498 of file blockfilterindex.cpp.
|
static |
Definition at line 331 of file blockfilterindex.cpp.
|
static |
Definition at line 350 of file blockfilterindex.cpp.
Maximum size of the cfheaders cache.
We have a limit to prevent a bug in filling this cache potentially turning into an OOM. At 2000 entries, this cache is big enough for a 2,000,000 length block chain, which we should be enough until ~2047.
Definition at line 51 of file blockfilterindex.cpp.
The index database stores three items for each block: the disk location of the encoded filter, its dSHA256 hash, and the header.
Those belonging to blocks on the active chain are indexed by height, and those belonging to blocks that have been reorganized out of the active chain are indexed by block hash. This ensures that filter data for any block that becomes part of the active chain can always be retrieved, alleviating timing concerns.
The filters themselves are stored in flat files and referenced by the LevelDB entries. This minimizes the amount of data written to LevelDB and keeps the database values constant size. The disk location of the next block filter to be written (represented as a FlatFilePos) is stored under the DB_FILTER_POS key.
Keys for the height index have the type [DB_BLOCK_HEIGHT, uint32 (BE)]. The height is represented as big-endian so that sequential reads of filters by height are fast. Keys for the hash index have the type [DB_BLOCK_HASH, uint256].
Definition at line 34 of file blockfilterindex.cpp.
Definition at line 35 of file blockfilterindex.cpp.
Definition at line 36 of file blockfilterindex.cpp.
The pre-allocation chunk size for fltr?????.dat files.
Definition at line 42 of file blockfilterindex.cpp.
|
static |
Definition at line 103 of file blockfilterindex.cpp.
Definition at line 39 of file blockfilterindex.cpp.