pub enum LedgerError {
Show 23 variants
UnknownAccount(AccountId),
UnitMismatch {
transfer: UnitId,
account: UnitId,
},
AccountUnitConflict {
id: AccountId,
},
InsufficientBalance {
account: AccountId,
needed: u128,
available: u128,
},
ZeroAmount,
AccountsMustDiffer(AccountId),
PostExceedsReservation {
requested: u128,
reserved: u128,
},
NotIssuerLiability(AccountId),
UnknownPendingTransfer(TransferId),
PendingTransferExpired(TransferId),
PendingTransferAlreadyPosted(TransferId),
PendingTransferAlreadyVoided(TransferId),
TimeoutOutOfBounds(u32),
IdTooOld(TransferId),
DuplicateTransferId {
id: TransferId,
original: Box<Outcome>,
},
Internal(String),
WriterLeaseHeld {
epoch: u64,
},
WriterLeaseLost {
expected: u64,
found: u64,
},
MirrorStale {
mirror_seq: u64,
db_seq: u64,
},
Poisoned(String),
CorruptRow(String),
SchemaIncompatible(String),
MintNotAuthorized(String),
}Expand description
Every way a ledger operation can fail. All variants are deterministic
functions of (current state, op) so a replay reproduces them exactly.
Variants§
UnknownAccount(AccountId)
A referenced account does not exist.
UnitMismatch
The transfer’s unit does not match a touched account’s unit (INV-1(b)).
Fields
AccountUnitConflict
open_account was called for an existing id but with a different unit.
InsufficientBalance
The debit account cannot cover the amount once pending holds are counted (overdraft floor, plan §2b.1).
Fields
ZeroAmount
Amount was zero (transfers must move a positive amount).
AccountsMustDiffer(AccountId)
A transfer named the same account on both sides. Double-entry requires two
distinct accounts (the TigerBeetle accounts_must_be_different rule) — a
self-transfer is meaningless and would collapse two deltas onto one row.
PostExceedsReservation
A partial post named an amount larger than the reservation.
NotIssuerLiability(AccountId)
credit was called with a debit side that is not an issuer-liability
account (INV-1: issuance must debit the issuer’s own liability).
UnknownPendingTransfer(TransferId)
A second-phase op named a pending id that does not exist.
PendingTransferExpired(TransferId)
The reservation’s deadline passed before this second phase committed (plan §2b.5 — the loser of the expiry-vs-post race).
PendingTransferAlreadyPosted(TransferId)
The reservation was already posted by an earlier second phase.
PendingTransferAlreadyVoided(TransferId)
The reservation was already voided by an earlier second phase.
TimeoutOutOfBounds(u32)
A reservation timeout was outside the permitted [1s, 24h] band.
IdTooOld(TransferId)
A replay arrived for a TransferId whose outcome row was already pruned
past the retention horizon (plan §2c). Distinguishable from “never seen”
so a caller escalates rather than blindly re-executing. (MemLedger never
prunes, so it never returns this; retention lands with a later work item.)
DuplicateTransferId
A replay was detected. The reference contract is transparent replay
(the stored crate::Outcome is returned verbatim), so MemLedger does
not surface this; it exists for backends that prefer an explicit signal,
carrying the original outcome.
Fields
id: TransferIdThe replayed id.
Internal(String)
An internal invariant/encoding failure. Fail-closed: the op is rejected without mutating state, and is retryable.
WriterLeaseHeld
Another process already holds the single-writer lease for this cell.
A durable backend admits exactly one writer per cell for the whole
instance lifetime (the premise crate::engine is written against).
A second instance is rejected at construction rather than allowed to
stage from its own mirror.
WriterLeaseLost
This instance’s writer lease was taken over by another instance.
The fencing epoch recorded in the database no longer matches the epoch this instance acquired, so its mirror may be arbitrarily stale. The op is refused and the instance poisons itself — it never writes again.
Fields
MirrorStale
The in-memory mirror did not describe the state that produced the committed head, so the staged deltas cannot be persisted.
Absolute account counters are only meaningful relative to the state they were computed from. Committing deltas staged against a stale mirror is exactly the lost-update bug, so the commit is refused inside the ordering boundary instead.
Fields
Poisoned(String)
The backend refused the op because a prior integrity failure poisoned this instance. Fail-closed and terminal: the process must restart (and rebuild from the journal) to write again.
CorruptRow(String)
A persisted row could not be decoded under the strict representation.
128-bit ids and amounts are exactly 16 bytes; anything else is a legacy or corrupt row. Decoding fails closed rather than truncating or substituting zero, which would silently alias distinct ids.
SchemaIncompatible(String)
The database schema version is not one this build can serve.
MintNotAuthorized(String)
An issuance was attempted without a valid authorization.
Minting is the only supply-growing operation (INV-1), so it is gated on
a verified, transfer-bound capability rather than on the caller merely
holding a backend. See crate::mint.
Trait Implementations§
Source§impl Clone for LedgerError
impl Clone for LedgerError
Source§fn clone(&self) -> LedgerError
fn clone(&self) -> LedgerError
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Debug for LedgerError
impl Debug for LedgerError
Source§impl<'de> Deserialize<'de> for LedgerError
impl<'de> Deserialize<'de> for LedgerError
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
Source§impl Display for LedgerError
impl Display for LedgerError
Source§impl Error for LedgerError
impl Error for LedgerError
1.30.0 · Source§fn source(&self) -> Option<&(dyn Error + 'static)>
fn source(&self) -> Option<&(dyn Error + 'static)>
1.0.0 · Source§fn description(&self) -> &str
fn description(&self) -> &str
use the Display impl or to_string()
Source§impl PartialEq for LedgerError
impl PartialEq for LedgerError
Source§fn eq(&self, other: &LedgerError) -> bool
fn eq(&self, other: &LedgerError) -> bool
self and other values to be equal, and is used by ==.