Skip to main content

Ledger

Struct Ledger 

Source
pub struct Ledger { /* private fields */ }

Implementations§

Source§

impl Ledger

Source

pub fn new(protocol_fee_address: String) -> Ledger

Source

pub fn balance_of(&self, address: &str, token: &TokenType) -> u64

Source

pub fn balances(&self) -> &HashMap<(String, TokenType), u64>

Source

pub fn issue(&mut self, to: &str, token: &TokenType, amount: u64)

Source

pub fn try_issue( &mut self, to: &str, token: &TokenType, amount: u64, ) -> Result<(), String>

Try to issue tokens, respecting supply caps from token_config

Source

pub fn transfer( &mut self, from: &str, to: &str, token: &TokenType, amount: u64, fee: u64, ) -> Result<TxReceipt, String>

Source

pub fn tx_history(&self) -> &[TxReceipt]

Source

pub fn tx_history_for(&self, address: &str) -> Vec<TxReceipt>

Source

pub fn block_height(&self) -> u64

Source

pub fn nonces(&self) -> &HashMap<String, u64>

Source

pub fn is_modified(&self) -> bool

Source

pub fn clear_modified(&mut self)

Source

pub fn protocol_fee_address(&self) -> &str

Source

pub fn total_supply(&self, token: &TokenType) -> u64

Source

pub fn current_nonce(&self, address: &str) -> u64

Source

pub fn total_supply_of(&self, token: &TokenType) -> u64

Source

pub fn update_interaction(&mut self, address: &str, token: &TokenType)

Record an interaction (transfer/issue) for an address-token pair

Source

pub fn last_interaction(&self, address: &str, token: &TokenType) -> Option<u64>

Get the block height of the last interaction for an address-token pair

Source

pub fn apply_decay( &self, address: &str, token: &TokenType, blocks_elapsed: u64, ) -> u64

Apply age-based decay to a balance based on blocks elapsed Returns the decayed amount using exponential decay formula

Source

pub fn aum_block_reward(&self, height: u64) -> u64

Calculate AUM block reward with halving schedule Halving occurs every 1M blocks

Source

pub fn add_minter(&mut self, token: &TokenType, minter: &str)

Add an address to the minter allowlist for a specific token

Source

pub fn is_authorized_minter(&self, token: &TokenType, minter: &str) -> bool

Check if an address is an authorized minter for a token

Source

pub fn try_issue_with_minter( &mut self, minter: &str, token: &TokenType, to: &str, amount: u64, ) -> Result<(), String>

Try to issue tokens with minter authorization check

Source

pub fn is_coinbase_mature( &self, _address: &str, height: u64, current_height: u64, ) -> bool

Source

pub fn apply_transfer( &mut self, tx: &TransferTransaction, miner: &str, ) -> Result<TxReceipt, String>

Source

pub fn rollback_transfer( &mut self, tx: &TransferTransaction, miner: &str, ) -> Result<(), String>

Source

pub fn apply_coinbase(&mut self, cb: &CoinbaseTransaction) -> Result<(), String>

Source

pub fn rollback_coinbase( &mut self, cb: &CoinbaseTransaction, ) -> Result<(), String>

Source

pub fn apply_block( &mut self, block: &HexBlock, ) -> Result<Vec<TxReceipt>, String>

Source

pub fn rollback_block(&mut self, block: &HexBlock) -> Result<(), String>

Source

pub fn compute_state_root(&self) -> [u8; 32]

Source

pub fn mint_tokens( &mut self, to: &str, token: &TokenType, amount: u64, ) -> Result<(), String>

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> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<A, B, T> HttpServerConnExec<A, B> for T
where B: Body,

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self> ⓘ

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self> ⓘ

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
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, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

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

fn try_from(value: U) -> Result<T, !>

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<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V

Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self> ⓘ
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self> ⓘ

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more