[#index_util]
= index&lowbar;util
:mrdocs:

Shared database key types for blockfilterindex and coinstatsindex&period;

== 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&period; Keys for the height index have the type &lsqb;DB&lowbar;BLOCK&lowbar;HEIGHT, uint32 (BE)&rsqb;&period; The height is represented as big&hyphen;endian so that sequential reads of filters by height are fast&period; Keys for the hash index have the type &lsqb;DB&lowbar;BLOCK&lowbar;HASH, uint256&rsqb;&period;

== Types

[cols="1,4"]
|===
| Name| Description
| xref:index_util/DBHashKey.adoc[`DBHashKey`] 
| Database key for an index entry looked up by block hash&period;
| xref:index_util/DBHeightKey.adoc[`DBHeightKey`] 
| Database key for an index entry looked up by block height&period;
|===


== Functions

[cols="1,4"]
|===
| Name| Description
| xref:index_util/CopyHeightIndexToHashIndex.adoc[`CopyHeightIndexToHashIndex`] 
| Copy an index entry from the height index to the hash index&period;
| xref:index_util/LookUpOne.adoc[`LookUpOne`] 
| Look up a single index entry for a block, trying the height index then the hash index&period;
|===


== Variables

[cols="1,4"]
|===
| Name| Description
| xref:index_util/DB_BLOCK_HASH.adoc[`DB&lowbar;BLOCK&lowbar;HASH`] 
| Key prefix byte identifying an entry in the hash index&period;
| xref:index_util/DB_BLOCK_HEIGHT.adoc[`DB&lowbar;BLOCK&lowbar;HEIGHT`] 
| Key prefix byte identifying an entry in the height index&period;
|===



[.small]#Created with https://www.mrdocs.com[MrDocs]#
