pub struct Account {
pub id: AccountId,
pub unit: UnitId,
pub purpose: Purpose,
pub debits_pending: u128,
pub debits_posted: u128,
pub credits_pending: u128,
pub credits_posted: u128,
pub flags: AccountFlags,
}Expand description
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.
Fields§
§id: AccountIdDerived identity (see AccountId::derive).
unit: UnitIdDenormalized unit; checked to match on every transfer touching this account.
purpose: PurposeDenormalized purpose; issuance checks this directly instead of inferring authority from flags.
debits_pending: u128Held-but-not-settled debits (outstanding reservations on the debit side).
debits_posted: u128Settled debits — monotonically increasing.
credits_pending: u128Held-but-not-settled credits.
credits_posted: u128Settled credits — monotonically increasing.
flags: AccountFlagsBehavioural flags (overdraft constraint, …).
Implementations§
Source§impl Account
impl Account
Sourcepub fn new(
id: AccountId,
unit: UnitId,
purpose: Purpose,
flags: AccountFlags,
) -> Self
pub fn new( id: AccountId, unit: UnitId, purpose: Purpose, flags: AccountFlags, ) -> Self
A freshly opened account with zeroed counters.
Sourcepub fn available(&self) -> u128
pub fn available(&self) -> u128
Amount available to spend for a debit-constrained account: settled net credit minus everything already promised. Pending credits do NOT count (they may still void) — the TigerBeetle rule. Saturating so it can never underflow into a huge number.
Sourcepub fn is_debit_constrained(&self) -> bool
pub fn is_debit_constrained(&self) -> bool
Whether this account enforces the overdraft floor.
Sourcepub fn view(&self, as_of_seq: u64) -> BalanceView
pub fn view(&self, as_of_seq: u64) -> BalanceView
A read-only projection of balances at a given journal sequence.