index_util

Shared database key types for blockfilterindex and coinstatsindex.

Description

Index data is usually indexed by height, but in case of a reorg, entries of blocks no longer in the main chain will be copied to a hash index by which they can still be queried. 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].

Types

NameDescription
DBHashKey Database key for an index entry looked up by block hash.
DBHeightKey Database key for an index entry looked up by block height.

Functions

NameDescription
CopyHeightIndexToHashIndex Copy an index entry from the height index to the hash index.
LookUpOne Look up a single index entry for a block, trying the height index then the hash index.

Variables

NameDescription
DB_BLOCK_HASH Key prefix byte identifying an entry in the hash index.
DB_BLOCK_HEIGHT Key prefix byte identifying an entry in the height index.