pub struct Ledger { /* private fields */ }Implementations§
Source§impl Ledger
impl Ledger
pub fn new(protocol_fee_address: String) -> Ledger
pub fn balance_of(&self, address: &str, token: &TokenType) -> u64
pub fn balances(&self) -> &HashMap<(String, TokenType), u64>
pub fn issue(&mut self, to: &str, token: &TokenType, amount: u64)
Sourcepub fn try_issue(
&mut self,
to: &str,
token: &TokenType,
amount: u64,
) -> Result<(), String>
pub fn try_issue( &mut self, to: &str, token: &TokenType, amount: u64, ) -> Result<(), String>
Try to issue tokens, respecting supply caps from token_config
pub fn transfer( &mut self, from: &str, to: &str, token: &TokenType, amount: u64, fee: u64, ) -> Result<TxReceipt, String>
pub fn tx_history(&self) -> &[TxReceipt]
pub fn tx_history_for(&self, address: &str) -> Vec<TxReceipt>
pub fn block_height(&self) -> u64
pub fn nonces(&self) -> &HashMap<String, u64>
pub fn is_modified(&self) -> bool
pub fn clear_modified(&mut self)
pub fn protocol_fee_address(&self) -> &str
pub fn total_supply(&self, token: &TokenType) -> u64
pub fn current_nonce(&self, address: &str) -> u64
pub fn total_supply_of(&self, token: &TokenType) -> u64
Sourcepub fn update_interaction(&mut self, address: &str, token: &TokenType)
pub fn update_interaction(&mut self, address: &str, token: &TokenType)
Record an interaction (transfer/issue) for an address-token pair
Sourcepub fn last_interaction(&self, address: &str, token: &TokenType) -> Option<u64>
pub fn last_interaction(&self, address: &str, token: &TokenType) -> Option<u64>
Get the block height of the last interaction for an address-token pair
Sourcepub fn apply_decay(
&self,
address: &str,
token: &TokenType,
blocks_elapsed: u64,
) -> u64
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
Sourcepub fn aum_block_reward(&self, height: u64) -> u64
pub fn aum_block_reward(&self, height: u64) -> u64
Calculate AUM block reward with halving schedule Halving occurs every 1M blocks
Sourcepub fn add_minter(&mut self, token: &TokenType, minter: &str)
pub fn add_minter(&mut self, token: &TokenType, minter: &str)
Add an address to the minter allowlist for a specific token
Check if an address is an authorized minter for a token
Sourcepub fn try_issue_with_minter(
&mut self,
minter: &str,
token: &TokenType,
to: &str,
amount: u64,
) -> Result<(), String>
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
pub fn is_coinbase_mature( &self, _address: &str, height: u64, current_height: u64, ) -> bool
pub fn apply_transfer( &mut self, tx: &TransferTransaction, miner: &str, ) -> Result<TxReceipt, String>
pub fn rollback_transfer( &mut self, tx: &TransferTransaction, miner: &str, ) -> Result<(), String>
pub fn apply_coinbase(&mut self, cb: &CoinbaseTransaction) -> Result<(), String>
pub fn rollback_coinbase( &mut self, cb: &CoinbaseTransaction, ) -> Result<(), String>
pub fn apply_block( &mut self, block: &HexBlock, ) -> Result<Vec<TxReceipt>, String>
pub fn rollback_block(&mut self, block: &HexBlock) -> Result<(), String>
pub fn compute_state_root(&self) -> [u8; 32]
pub fn mint_tokens( &mut self, to: &str, token: &TokenType, amount: u64, ) -> Result<(), String>
Auto Trait Implementations§
impl Freeze for Ledger
impl RefUnwindSafe for Ledger
impl Send for Ledger
impl Sync for Ledger
impl Unpin for Ledger
impl UnsafeUnpin for Ledger
impl UnwindSafe for Ledger
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more