mirror of
https://github.com/logos-blockchain/lssa.git
synced 2026-01-06 23:33:10 +00:00
fix: docs added
This commit is contained in:
parent
5f4d6c0f8d
commit
a24a40f4bc
@ -2,8 +2,9 @@ use serde::{Deserialize, Serialize};
|
|||||||
use std::path::PathBuf;
|
use std::path::PathBuf;
|
||||||
|
|
||||||
#[derive(Debug, Serialize, Deserialize, Clone)]
|
#[derive(Debug, Serialize, Deserialize, Clone)]
|
||||||
|
///Helperstruct for account serialization
|
||||||
pub struct AccountInitialData {
|
pub struct AccountInitialData {
|
||||||
///Hex encoded AccountAddress
|
///Hex encoded `AccountAddress`
|
||||||
pub addr: String,
|
pub addr: String,
|
||||||
pub balance: u64,
|
pub balance: u64,
|
||||||
}
|
}
|
||||||
|
|||||||
@ -40,19 +40,27 @@ impl SequencerAccountsStore {
|
|||||||
Self { accounts }
|
Self { accounts }
|
||||||
}
|
}
|
||||||
|
|
||||||
|
///Register new account in accounts store
|
||||||
|
///
|
||||||
|
///Starts with zero public balance
|
||||||
pub fn register_account(&mut self, account_addr: AccountAddress) {
|
pub fn register_account(&mut self, account_addr: AccountAddress) {
|
||||||
self.accounts
|
self.accounts
|
||||||
.insert(account_addr, AccountPublicData::new(account_addr));
|
.insert(account_addr, AccountPublicData::new(account_addr));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
///Check, if `account_addr` present in account store
|
||||||
pub fn contains_account(&self, account_addr: &AccountAddress) -> bool {
|
pub fn contains_account(&self, account_addr: &AccountAddress) -> bool {
|
||||||
self.accounts.contains_key(account_addr)
|
self.accounts.contains_key(account_addr)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
///Check `account_addr` balance,
|
||||||
|
///
|
||||||
|
///returns `None`, if account address not found
|
||||||
pub fn get_account_balance(&self, account_addr: &AccountAddress) -> Option<u64> {
|
pub fn get_account_balance(&self, account_addr: &AccountAddress) -> Option<u64> {
|
||||||
self.accounts.get(account_addr).map(|acc| acc.balance)
|
self.accounts.get(account_addr).map(|acc| acc.balance)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
///Remove account from storage
|
||||||
pub fn unregister_account(&mut self, account_addr: AccountAddress) {
|
pub fn unregister_account(&mut self, account_addr: AccountAddress) {
|
||||||
self.accounts.remove(&account_addr);
|
self.accounts.remove(&account_addr);
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user