Skip to main content

Module store

Module store 

Source
Expand description

The storage seam: where the ledger lives.

The ledger is two small tables in the app’s own database (Phase 3 spec, section 5.1). An app plugs its database in by implementing LedgerStore, or uses one of the two stores this crate ships:

  • rusqlite::Connection (feature sqlite): the tables <prefix>replica_collections and <prefix>replica_rows, written in BEGIN IMMEDIATE transactions.
  • MemoryLedger: a ledger that lives as long as the process. A new process starts a new epoch, so every device takes one full copy after each start. For an app with no database of its own.

The helper’s logic sees only LedgerTx; it never writes SQL.

Structs§

CollectionRecord
One collection’s ledger header (replica_collections).
LedgerEntry
One row of the ledger (replica_rows): a key and what is known about it, never its value.
MemoryLedger
A ledger held in process memory. Cloning it copies the ledger as it is now.
Pruned
What LedgerTx::prune_tombstones did.

Traits§

LedgerStore
A database the ledger can live in.
LedgerTx
Ledger reads and writes inside one write transaction. Keys sort by their UTF-8 bytes (SQLite’s BINARY collation, Rust’s str order).