Skip to main content

LedgerError

Enum LedgerError 

Source
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

§transfer: UnitId

The unit named on the transfer.

§account: UnitId

The unit denormalized on the account.

§

AccountUnitConflict

open_account was called for an existing id but with a different unit.

Fields

§id: AccountId

The account id whose unit conflicts.

§

InsufficientBalance

The debit account cannot cover the amount once pending holds are counted (overdraft floor, plan §2b.1).

Fields

§account: AccountId

The debit account.

§needed: u128

Amount requested.

§available: u128

Amount actually available.

§

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.

Fields

§requested: u128

Requested post amount.

§reserved: u128

The reserved amount.

§

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: TransferId

The replayed id.

§original: Box<Outcome>

The original recorded outcome, boxed to keep the enum small.

§

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.

Fields

§epoch: u64

The epoch of the lease currently recorded in the database.

§

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

§expected: u64

The epoch this instance acquired at startup.

§found: u64

The epoch currently recorded in the database.

§

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

§mirror_seq: u64

The head sequence the mirror staged against.

§db_seq: u64

The head sequence actually found in the database.

§

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

Source§

fn clone(&self) -> LedgerError

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for LedgerError

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl<'de> Deserialize<'de> for LedgerError

Source§

fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>
where __D: Deserializer<'de>,

Deserialize this value from the given Serde deserializer. Read more
Source§

impl Display for LedgerError

Source§

fn fmt(&self, __formatter: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Error for LedgerError

1.30.0 · Source§

fn source(&self) -> Option<&(dyn Error + 'static)>

Returns the lower-level source of this error, if any. Read more
1.0.0 · Source§

fn description(&self) -> &str

👎Deprecated since 1.42.0:

use the Display impl or to_string()

1.0.0 · Source§

fn cause(&self) -> Option<&dyn Error>

👎Deprecated since 1.33.0:

replaced by Error::source, which can support downcasting

Source§

fn provide<'a>(&'a self, request: &mut Request<'a>)

🔬This is a nightly-only experimental API. (error_generic_member_access)
Provides type-based access to context intended for error reports. Read more
Source§

impl PartialEq for LedgerError

Source§

fn eq(&self, other: &LedgerError) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 (const: unstable) · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl Serialize for LedgerError

Source§

fn serialize<__S>(&self, __serializer: __S) -> Result<__S::Ok, __S::Error>
where __S: Serializer,

Serialize this value into the given Serde serializer. Read more
Source§

impl Eq for LedgerError

Source§

impl StructuralPartialEq for LedgerError

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T> ToString for T
where T: Display + ?Sized,

Source§

fn to_string(&self) -> String

Converts the given value to a String. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<T> DeserializeOwned for T
where T: for<'de> Deserialize<'de>,