pub struct Blockchain {Show 20 fields
pub utxoset: UtxoSet,
pub blockring: BlockRing,
pub blocks: AHashMap<SaitoHash, Block>,
pub wallet_lock: Arc<RwLock<Wallet>>,
pub genesis_block_id: u64,
pub fork_id: Option<SaitoHash>,
pub last_block_hash: SaitoHash,
pub last_block_id: u64,
pub last_timestamp: u64,
pub last_burnfee: Currency,
pub genesis_timestamp: u64,
pub lowest_acceptable_timestamp: u64,
pub lowest_acceptable_block_hash: SaitoHash,
pub lowest_acceptable_block_id: u64,
pub social_stake_requirement: Currency,
pub social_stake_period: u64,
pub genesis_period: BlockId,
pub checkpoint_found: bool,
pub initial_token_supply: Currency,
pub last_issuance_written_on: BlockId,
/* private fields */
}
Fields§
§utxoset: UtxoSet
§blockring: BlockRing
§blocks: AHashMap<SaitoHash, Block>
§wallet_lock: Arc<RwLock<Wallet>>
§genesis_block_id: u64
§fork_id: Option<SaitoHash>
§last_block_hash: SaitoHash
§last_block_id: u64
§last_timestamp: u64
§last_burnfee: Currency
§genesis_timestamp: u64
§lowest_acceptable_timestamp: u64
§lowest_acceptable_block_hash: SaitoHash
§lowest_acceptable_block_id: u64
§genesis_period: BlockId
§checkpoint_found: bool
§initial_token_supply: Currency
§last_issuance_written_on: BlockId
Implementations§
Source§impl Blockchain
impl Blockchain
pub fn new( wallet_lock: Arc<RwLock<Wallet>>, genesis_period: BlockId, social_stake: Currency, social_stake_period: BlockId, ) -> Self
pub fn init(&mut self) -> Result<(), Error>
pub fn set_fork_id(&mut self, fork_id: SaitoHash)
pub async fn add_block( &mut self, block: Block, storage: &mut Storage, mempool: &mut Mempool, configs: &(dyn Configuration + Send + Sync), ) -> AddBlockResult
pub async fn write_issuance_file( &self, threshold: Currency, issuance_file_path: &str, storage: &mut Storage, )
pub fn generate_fork_id(&self, block_id: u64) -> Option<ForkId>
pub fn get_latest_block(&self) -> Option<&Block>
pub fn get_latest_block_hash(&self) -> SaitoHash
pub fn get_latest_block_id(&self) -> BlockId
pub fn get_latest_unlocked_stake_block_id(&self) -> BlockId
pub fn get_block_sync(&self, block_hash: &SaitoHash) -> Option<&Block>
pub fn get_block(&self, block_hash: &SaitoHash) -> Option<&Block>
pub fn get_mut_block(&mut self, block_hash: &SaitoHash) -> Option<&mut Block>
pub fn is_block_indexed(&self, block_hash: SaitoHash) -> bool
pub fn contains_block_hash_at_block_id( &self, block_id: u64, block_hash: SaitoHash, ) -> bool
pub fn is_golden_ticket_count_valid( &self, previous_block_hash: SaitoHash, current_block_has_golden_ticket: bool, is_browser: bool, is_spv: bool, ) -> bool
Sourcepub async fn on_chain_reorganization(
&mut self,
block_id: u64,
block_hash: SaitoHash,
longest_chain: bool,
storage: &Storage,
configs: &(dyn Configuration + Send + Sync),
) -> WalletUpdateStatus
pub async fn on_chain_reorganization( &mut self, block_id: u64, block_hash: SaitoHash, longest_chain: bool, storage: &Storage, configs: &(dyn Configuration + Send + Sync), ) -> WalletUpdateStatus
keeps any blockchain variables like fork_id or genesis_period tracking variables updated as the chain gets new blocks. also pre-loads any blocks needed to improve performance.
pub async fn add_blocks_from_mempool( &mut self, mempool_lock: Arc<RwLock<Mempool>>, network: Option<&Network>, storage: &mut Storage, sender_to_miner: Option<Sender<MiningEvent>>, sender_to_router: Option<Sender<RoutingEvent>>, configs: &(dyn Configuration + Send + Sync), )
pub fn add_ghost_block( &mut self, id: u64, previous_block_hash: SaitoHash, ts: Timestamp, pre_hash: SaitoHash, gt: bool, hash: SaitoHash, )
pub async fn reset(&mut self)
pub async fn save(&self)
pub fn get_utxoset_data(&self) -> HashMap<SaitoPublicKey, Currency>
pub fn get_slips_for(&self, public_key: SaitoPublicKey) -> Vec<Slip>
pub fn get_balance_snapshot( &self, keys: Vec<SaitoPublicKey>, configs: &(dyn Configuration + Send + Sync), ) -> BalanceSnapshot
pub fn is_slip_unlocked(&self, utxo_key: &SaitoUTXOSetKey) -> bool
pub fn set_safe_to_prune_transaction(&mut self, block_id: u64)
pub fn calculate_current_supply(&self) -> Currency
pub async fn check_total_supply( &mut self, configs: &(dyn Configuration + Send + Sync), )
Trait Implementations§
Auto Trait Implementations§
impl Freeze for Blockchain
impl !RefUnwindSafe for Blockchain
impl Send for Blockchain
impl Sync for Blockchain
impl Unpin for Blockchain
impl !UnwindSafe for Blockchain
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