 |
Bitcoin Core
21.99.0
P2P Digital Currency
|
Go to the documentation of this file.
5 #ifndef BITCOIN_INDEX_BLOCKFILTERINDEX_H
6 #define BITCOIN_INDEX_BLOCKFILTERINDEX_H
29 std::unique_ptr<BaseIndex::DB>
m_db;
57 size_t n_cache_size,
bool f_memory =
false,
bool f_wipe =
false);
69 std::vector<BlockFilter>& filters_out)
const;
73 std::vector<uint256>& hashes_out)
const;
90 size_t n_cache_size,
bool f_memory =
false,
bool f_wipe =
false);
102 #endif // BITCOIN_INDEX_BLOCKFILTERINDEX_H
Batch of changes queued to be written to a CDBWrapper.
std::unique_ptr< BaseIndex::DB > m_db
size_t WriteFilterToDisk(FlatFilePos &pos, const BlockFilter &filter)
BlockFilterIndex is used to store and retrieve block filters, hashes, and headers for a range of bloc...
bool CommitInternal(CDBBatch &batch) override
Virtual method called internally by Commit that can be overridden to atomically commit more index sta...
Base class for indices of blockchain data.
bool Init() override
Initialize internal state from the database and block index.
BlockFilterType m_filter_type
bool LookupFilterRange(int start_height, const CBlockIndex *stop_index, std::vector< BlockFilter > &filters_out) const
Get a range of filters between two heights on a chain.
bool Rewind(const CBlockIndex *current_tip, const CBlockIndex *new_tip) override
Rewind index to an earlier chain tip during a chain reorg.
BlockFilterIndex * GetBlockFilterIndex(BlockFilterType filter_type)
Get a block filter index by type.
bool ReadFilterFromDisk(const FlatFilePos &pos, BlockFilter &filter) const
std::unordered_map< uint256, uint256, FilterHeaderHasher > m_headers_cache GUARDED_BY(m_cs_headers_cache)
cache of block hash to filter header, to avoid disk access when responding to getcfcheckpt.
FlatFilePos m_next_filter_pos
bool LookupFilterHashRange(int start_height, const CBlockIndex *stop_index, std::vector< uint256 > &hashes_out) const
Get a range of filter hashes between two heights on a chain.
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.
bool WriteBlock(const CBlock &block, const CBlockIndex *pindex) override
Write update index entries for a newly connected block.
static constexpr int CFCHECKPT_INTERVAL
Interval between compact filter checkpoints.
bool LookupFilter(const CBlockIndex *block_index, BlockFilter &filter_out) const
Get a single filter by block.
The database stores a block locator of the chain the database is synced to so that the index can effi...
void DestroyAllBlockFilterIndexes()
Destroy all open block filter indexes.
BlockFilterType GetFilterType() const
BaseIndex::DB & GetDB() const override
void ForEachBlockFilterIndex(std::function< void(BlockFilterIndex &)> fn)
Iterate over all running block filter indexes, invoking fn on each.
bool DestroyBlockFilterIndex(BlockFilterType filter_type)
Destroy the block filter index with the given type.
BlockFilterIndex(BlockFilterType filter_type, size_t n_cache_size, bool f_memory=false, bool f_wipe=false)
Constructs the index, which becomes available to be queried.
The block chain is a tree shaped structure starting with the genesis block at the root,...
bool LookupFilterHeader(const CBlockIndex *block_index, uint256 &header_out)
Get a single filter header by block.
std::unique_ptr< FlatFileSeq > m_filter_fileseq
const char * GetName() const override
Get the name of the index for display in logs.
Complete block filter struct as defined in BIP 157.