Bitcoin Core  27.99.0
P2P Digital Currency
Functions | Variables
blockfilterindex.cpp File Reference
#include <map>
#include <clientversion.h>
#include <common/args.h>
#include <dbwrapper.h>
#include <hash.h>
#include <index/blockfilterindex.h>
#include <logging.h>
#include <node/blockstorage.h>
#include <undo.h>
#include <util/fs_helpers.h>
#include <validation.h>
Include dependency graph for blockfilterindex.cpp:

Go to the source code of this file.

Functions

static bool CopyHeightIndexToHashIndex (CDBIterator &db_it, CDBBatch &batch, const std::string &index_name, int start_height, int stop_height)
 
static bool LookupOne (const CDBWrapper &db, const CBlockIndex *block_index, DBVal &result)
 
static bool LookupRange (CDBWrapper &db, const std::string &index_name, int start_height, const CBlockIndex *stop_index, std::vector< DBVal > &results)
 
BlockFilterIndexGetBlockFilterIndex (BlockFilterType filter_type)
 Get a block filter index by type. More...
 
void ForEachBlockFilterIndex (std::function< void(BlockFilterIndex &)> fn)
 Iterate over all running block filter indexes, invoking fn on each. More...
 
bool InitBlockFilterIndex (std::function< std::unique_ptr< interfaces::Chain >()> make_chain, BlockFilterType filter_type, size_t n_cache_size, bool f_memory, bool f_wipe)
 Initialize a block filter index for the given type if one does not already exist. More...
 
bool DestroyBlockFilterIndex (BlockFilterType filter_type)
 Destroy the block filter index with the given type. More...
 
void DestroyAllBlockFilterIndexes ()
 Destroy all open block filter indexes. More...
 

Variables

constexpr uint8_t DB_BLOCK_HASH {'s'}
 
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. More...
 
constexpr size_t CF_HEADERS_CACHE_MAX_SZ {2000}
 Maximum size of the cfheaders cache We have a limit to prevent a bug in filling this cache potentially turning into an OOM. More...
 
static std::map< BlockFilterType, BlockFilterIndexg_filter_indexes
 

Function Documentation

◆ CopyHeightIndexToHashIndex()

static bool CopyHeightIndexToHashIndex ( CDBIterator db_it,
CDBBatch batch,
const std::string &  index_name,
int  start_height,
int  stop_height 
)
static

Definition at line 291 of file blockfilterindex.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ DestroyAllBlockFilterIndexes()

void DestroyAllBlockFilterIndexes ( )

Destroy all open block filter indexes.

Definition at line 522 of file blockfilterindex.cpp.

Here is the caller graph for this function:

◆ DestroyBlockFilterIndex()

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 517 of file blockfilterindex.cpp.

Here is the caller graph for this function:

◆ ForEachBlockFilterIndex()

void ForEachBlockFilterIndex ( std::function< void(BlockFilterIndex &)>  fn)

Iterate over all running block filter indexes, invoking fn on each.

Definition at line 502 of file blockfilterindex.cpp.

Here is the caller graph for this function:

◆ GetBlockFilterIndex()

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 496 of file blockfilterindex.cpp.

Here is the caller graph for this function:

◆ InitBlockFilterIndex()

bool InitBlockFilterIndex ( std::function< std::unique_ptr< interfaces::Chain >()>  make_chain,
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 507 of file blockfilterindex.cpp.

Here is the caller graph for this function:

◆ LookupOne()

static bool LookupOne ( const CDBWrapper db,
const CBlockIndex block_index,
DBVal &  result 
)
static

Definition at line 342 of file blockfilterindex.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ LookupRange()

static bool LookupRange ( CDBWrapper db,
const std::string &  index_name,
int  start_height,
const CBlockIndex stop_index,
std::vector< DBVal > &  results 
)
static

Definition at line 360 of file blockfilterindex.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

Variable Documentation

◆ CF_HEADERS_CACHE_MAX_SZ

constexpr size_t CF_HEADERS_CACHE_MAX_SZ {2000}
constexpr

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 45 of file blockfilterindex.cpp.

◆ DB_BLOCK_HASH

constexpr uint8_t DB_BLOCK_HASH {'s'}
constexpr

Definition at line 33 of file blockfilterindex.cpp.

◆ DB_BLOCK_HEIGHT

constexpr uint8_t DB_BLOCK_HEIGHT {'t'}
constexpr

Definition at line 34 of file blockfilterindex.cpp.

◆ DB_FILTER_POS

constexpr uint8_t DB_FILTER_POS {'P'}
constexpr

Definition at line 35 of file blockfilterindex.cpp.

◆ FLTR_FILE_CHUNK_SIZE

constexpr unsigned int FLTR_FILE_CHUNK_SIZE = 0x100000
constexpr

The pre-allocation chunk size for fltr?????.dat files.

Definition at line 39 of file blockfilterindex.cpp.

◆ g_filter_indexes

std::map<BlockFilterType, BlockFilterIndex> g_filter_indexes
static

Definition at line 98 of file blockfilterindex.cpp.

◆ MAX_FLTR_FILE_SIZE

constexpr unsigned int MAX_FLTR_FILE_SIZE = 0x1000000
constexpr

Definition at line 37 of file blockfilterindex.cpp.