Expand description
Static indexes for closed history: transaction by hash and account history. They are built once over an immutable range of ledgers; fresh ledgers still go into the fjall indexes.
Transaction by hash (XTXH). The range’s transactions are numbered in
order: ledger, then position in the ledger. Buckets are keyed by the top b
bits of the hash; a bucket holds fixed-width entries: a 16-bit fingerprint (the
next bits of the hash) and the transaction number. The full hash is not stored:
a candidate is read and checked by recomputing its hash, so a matching
fingerprint never returns the wrong transaction. A false candidate for a missing
hash happens with probability about bucket size / 65 536.
Account history (XACC). Directory: account (20 bytes, ascending),
offset and entry count; the lists hold positions (ledger, TransactionIndex) in
ascending order, delta-encoded as varints. List order is account_tx order.
Version 2 stores the same lists with Rice codes: a position becomes a transaction
number within the partition (by ledger, then by TransactionIndex; the transaction
count of every ledger is stored in the index), and the differences between
numbers are written with one Rice parameter per list; rare large differences are
written as length and bits. Lists longer than SKIP_EVERY get entry points every
SKIP_EVERY positions (bit offset and the number before the block), so an
account_tx page in either direction decodes one or two blocks, not the whole list.
Structs§
- Account
File - XACC v2 from disk: memory holds anchor points for ledger starts (every
MARK-th) and a sparse directory (everySPARSE-th entry); ledger starts between anchors, directory entries, entry points and list blocks are read with pread on demand. - Account
Index - Account history index.
- TxHash
File - XTXH from disk: only the parameters live in memory; ledger starts, the bucket table and bucket entries are read with pread on demand (the full history is hundreds of millions of ledgers, too many to keep in memory).
- TxHash
Index - “Transaction by hash” index over a range of ledgers.
Functions§
- build_
account_ index - Builds the account history index from entries (account → positions).
- build_
account_ index_ v2 - Builds a version 2 account history index with Rice-coded lists.
countsis the transaction count of each ledger in the partition, in order. - build_
tx_ index - Builds the index:
ledgersholds, for each ledger of the range in order, the hashes of its transactions in storage order. - build_
tx_ index_ tops - Same, from the top 64 bits of the hashes: (bits, transaction number in the range) and each ledger’s transaction count, without full hashes in memory.
Type Aliases§
- Posting
- A position in account history: ledger and TransactionIndex.