[#txindex-02]
= txindex
:mrdocs:

Database key types and constants for the transaction index&period;

== Description

Database layout&colon;

&lsqb;&apos;x&apos;, hash prefix, block seq, tx offset&rsqb;&hyphen;&gt; (empty) &lsqb;&apos;s&apos;, block seq&rsqb;&hyphen;&gt; block hash &lsqb;&apos;h&apos;, block hash&rsqb;&hyphen;&gt; block seq &lsqb;&quot;next&lowbar;block&lowbar;seq&quot;&rsqb;&hyphen;&gt; next block seq to assign &lsqb;&quot;txid&lowbar;hash&lowbar;salt&quot;&rsqb;&hyphen;&gt; txid hasher salt &lsqb;&quot;best&lowbar;block&lowbar;v2&quot;&rsqb;&hyphen;&gt; current sync locator &lsqb;&apos;t&apos;, txid&rsqb;&hyphen;&gt; legacy CDiskTxPos &lsqb;&apos;B&apos;&rsqb;&hyphen;&gt; legacy sync locator

== Types

[cols="1,4"]
|===
| Name| Description
| xref:txindex-02/BlockHashKey.adoc[`BlockHashKey`] 
| Key for looking up the sequence number assigned to the block with the given hash&period;
| xref:txindex-02/BlockSeqKey.adoc[`BlockSeqKey`] 
| Key for looking up the hash of the block with the given sequence number&period;
| xref:txindex-02/BlockTxPosition.adoc[`BlockTxPosition`] 
| The location of a transaction&colon; the sequence number of the block that contains it and the transaction&apos;s serialized byte offset from the start of that block (including the header), so the on&hyphen;disk position is simply block&lowbar;data&lowbar;pos &plus; tx&lowbar;offset&lowbar;in&lowbar;block&period;
| xref:txindex-02/DBKey.adoc[`DBKey`] 
| Hashed txindex key&colon; a truncated txid hash prefix plus the block position&period;
|===


== Type Aliases

[cols="1,4"]
|===
| Name| Description
| xref:txindex-02/TxHashKeyPrefix.adoc[`TxHashKeyPrefix`] 
| Integer type holding the truncated txid hash prefix of a key&period;
|===


== Functions

[cols="1,4"]
|===
| Name| Description
| xref:txindex-02/CreateKeyPrefix.adoc[`CreateKeyPrefix`] 
| Compute the txid&hyphen;hash key prefix for a transaction&period;
| xref:txindex-02/LegacyTxKey.adoc[`LegacyTxKey`] 
| Key of a legacy (pre&hyphen;hashing) txindex row&colon; the full txid under the &apos;t&apos; prefix&period;
| xref:txindex-02/operator_eq.adoc[`operator&equals;&equals;`] 
| Compare two positions for equality by block sequence and offset&period;
|===


== Variables

[cols="1,4"]
|===
| Name| Description
| xref:txindex-02/BLOCK_HEADER_SIZE.adoc[`BLOCK&lowbar;HEADER&lowbar;SIZE`] 
| Serialized size of a block header, the offset of the first byte after it&period;
| xref:txindex-02/DB_BEST_BLOCK_V2.adoc[`DB&lowbar;BEST&lowbar;BLOCK&lowbar;V2`] 
| Key holding the sync locator for the current (v2) index format&period;
| xref:txindex-02/DB_BLOCK_HASH.adoc[`DB&lowbar;BLOCK&lowbar;HASH`] 
| Key prefix mapping a block hash to its sequence number&period;
| xref:txindex-02/DB_BLOCK_SEQ.adoc[`DB&lowbar;BLOCK&lowbar;SEQ`] 
| Key prefix mapping a block sequence number to its block hash&period;
| xref:txindex-02/DB_NEXT_BLOCK_SEQ.adoc[`DB&lowbar;NEXT&lowbar;BLOCK&lowbar;SEQ`] 
| Key holding the next block sequence number to assign&period;
| xref:txindex-02/DB_TXID_HASH_SALT.adoc[`DB&lowbar;TXID&lowbar;HASH&lowbar;SALT`] 
| Key holding the salt used to hash txids&period;
| xref:txindex-02/DB_TXINDEX.adoc[`DB&lowbar;TXINDEX`] 
| Prefix of a legacy (pre&hyphen;hashing) txindex row&period;
| xref:txindex-02/DB_TXINDEX_HASHED.adoc[`DB&lowbar;TXINDEX&lowbar;HASHED`] 
| Key prefix for a hashed txindex row keyed by txid hash prefix and position&period;
| xref:txindex-02/EMPTY_VALUE.adoc[`EMPTY&lowbar;VALUE`] 
| Empty value of a hashed txindex row, whose position is encoded in its key&period;
| xref:txindex-02/HASH_PREFIX_SIZE.adoc[`HASH&lowbar;PREFIX&lowbar;SIZE`] 
| Number of leading txid&hyphen;hash bytes kept in a hashed txindex key&period;
|===



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