Skip to main content

Module types

Module types 

Source
Expand description

Core data model for the accounting plane (plan §2.0).

Everything here is no_std-friendly in spirit (no I/O, no clock, no tokio) so the whole crate builds for wasm32-unknown-unknown. Amounts are u128 minor units; no floats anywhere (INV grep-gate: f32|f64 forbidden outside benches).

Structs§

Account
TigerBeetle-compatible account state (plan §2.0). The four counters are u128 minor units. *_posted only ever grow; *_pending rise on reserve and fall on post/void/expire. Balances are differences of counters, never stored.
AccountFlags
TigerBeetle-compatible account flags.
AccountId
128-bit account identity. Deterministic function of the canonical tuple, so any party that knows (ledger_id, owner, unit, purpose) can derive it with no allocation-time coordination, and it is TigerBeetle-compatible (TB account ids are u128).
AccountSpec
Everything needed to open (or idempotently re-open) an account.
BalanceView
Read-only balance projection returned by crate::LedgerBackend::balance.
Cid
Opaque content identifier for a UCAN allocation grant. Kept as raw bytes so this crate carries no hyprstream-pds dependency (D3 crate boundary): the ledger only correlates a spend to its grant, it never parses the CID.
Did
A decentralized identifier, carried opaquely (did:web / did:key / did:at9p). The ledger crate treats DIDs as pseudonymous strings and never resolves or interprets them — per the #924 P0 constraint, no legal-identity fields live in this model; a DID is the only principal handle.
IssueTransfer
Single-phase issuance (INV-1): the only entry point that grows a unit’s supply. The debit side MUST be the issuer’s IssuerLiability account for the unit; the credit side is the destination.
Outcome
The recorded result of an operation. Stored under the op’s TransferId; a replay returns this verbatim (PLAN DECISION 3 — original result, including original errors).
PendingReservation
A tracked phase-1 reservation. Held in CF(pending) in RocksLedger; a BTreeMap entry in MemLedger.
Transfer
A value movement between two accounts of the same unit (INV-1(b): one unit field, never two — cross-issuer movement is two linked transfers).
TransferId
Client-supplied 128-bit transfer id (plan §2c). The id IS the idempotency key: replaying it returns the original outcome (including original errors).
UnitId
A resource unit. INV-1(a): the unit names its issuer. Two units with different issuers are different units, full stop — there is no bearer-token representation of value that omits the issuer.

Enums§

PendingState
The lifecycle state of a two-phase reservation (plan §2b).
Purpose
What an account is for. The purpose participates in the account id, so two accounts of the same owner/unit but different purpose are distinct rows.
TransferResult
What a successful op did — the positive half of an Outcome.