Skip to main content

Module skiplist

Module skiplist 

Source
Expand description

Skip lists: the LedgerHashes objects the network keeps in ledger state.

Every ledger updates two of them before its transactions run (they are not in any transaction’s metadata):

  • the short list, key SHA-512Half(0x0073), holds the hashes of the previous 256 ledgers;
  • when the previous ledger’s index is a multiple of 256, its hash is appended to the long list of its group of 65536 ledgers, key SHA-512Half(0x0073, index >> 16 as u32). A group’s list is never removed, so the latest state holds the hash of every 256th ledger back to the start of history.

Any hash in either list is the hash of an earlier ledger of the same chain: only the protocol writes these objects, and only with parent hashes. A state proof of a list in a confirmed ledger therefore confirms every ledger whose hash is in it, and a header chain of at most 255 ledgers reaches any ledger from the next multiple of 256.

Constants§

HASHES
The Hashes field (Vector256, code 2).
LEDGER_HASHES
LedgerEntryType of a skip list: h.

Functions§

covering
The first multiple of 256 at or after seq: the ledger whose hash a long list holds and from which a chain reaches seq.
hashes
The hashes of a serialized LedgerHashes object.
long_key
Key of the long list that holds the hash of ledger seq when seq is a multiple of 256.
short_key
Key of the short list (the previous 256 ledgers).