index_util::CopyHeightIndexToHashIndex

Copy an index entry from the height index to the hash index.

Synopsis

Declared in <index/db_key.h>

template<typename DBVal>
[[nodiscard]]
static
bool
CopyHeightIndexToHashIndex(
    CDBIterator& db_it,
    CDBBatch& batch,
    std::string const& index_name,
    int height);

Description

Used during a reorg so entries for blocks no longer on the main chain remain queryable by hash.

Return Value

True on success, false if the expected entry could not be read.

NOTE

The return value should not be discarded.

Template Parameters

NameDescription
DBValType of the value stored for the entry.

Parameters

NameDescription
db_itIterator positioned to read the height-indexed entry.
batchWrite batch that the hash-indexed copy is added to.
index_nameName of the index, used for error logging.
heightBlock height of the entry to copy.