Expand description
A ledger’s state changes, stored as a diff against what is already known: the previous version of the object and the transaction metadata.
Measured on 2048 mainnet ledgers (1.08 million objects, each one restored byte for byte): full objects take 26.8 KB per ledger in zstd-19 blocks, this diff takes 8.8.
For every created or modified object a “base” is built, with no protocol logic, only from what is at hand:
- the object was touched by the ledger’s transactions: the previous version (nothing for a created one), overlaid with the fields from the last touching transaction (NewFields for a created object, FinalFields for a modified one), LedgerEntryType, PreviousTxnID and PreviousTxnLgrSeq set to that transaction and this ledger, and Flags = 0 if the field is missing (every object has it, and a zero value never appears in NewFields);
- not touched (LedgerHashes and the like): the previous version.
What gets stored is the remainder: changed and new fields in full, changed Vector256 lists as a patch (removed positions, inserted items), deleted fields by code. Whatever is missing from the metadata (directory Indexes, page numbers) ends up in the remainder.
Encoding checks itself: every object is rebuilt right away and compared byte for byte. If it does not match, or the remainder is not shorter than the object, the full object is stored.
Structs§
- Touch
- The last transaction in the ledger that touched the object: its hash, its fields for the object and LedgerEntryType (raw field bytes).
Functions§
- decode
- Changes of a ledger from a format 3 record;
lis the ledger with its transactions. - encode
- Changes of ledger
seqas a format 3 record. Returns the record and how many objects had to be stored in full. - touches
- Objects touched by the ledger’s transactions, in order of application.
Type Aliases§
- Prev
- The previous version of the object, as of the ledger before this one;
Noneif it did not exist.