Struct Blockchain

Source
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§social_stake_requirement: Currency§social_stake_period: u64§genesis_period: BlockId§checkpoint_found: bool§initial_token_supply: Currency§last_issuance_written_on: BlockId

Implementations§

Source§

impl Blockchain

Source

pub fn new( wallet_lock: Arc<RwLock<Wallet>>, genesis_period: BlockId, social_stake: Currency, social_stake_period: BlockId, ) -> Self

Source

pub fn init(&mut self) -> Result<(), Error>

Source

pub fn set_fork_id(&mut self, fork_id: SaitoHash)

Source

pub async fn add_block( &mut self, block: Block, storage: &mut Storage, mempool: &mut Mempool, configs: &(dyn Configuration + Send + Sync), ) -> AddBlockResult

Source

pub async fn write_issuance_file( &self, threshold: Currency, issuance_file_path: &str, storage: &mut Storage, )

Source

pub fn generate_fork_id(&self, block_id: u64) -> Option<ForkId>

Source

pub fn generate_last_shared_ancestor( &self, peer_latest_block_id: u64, fork_id: SaitoHash, ) -> u64

Source

pub fn get_latest_block(&self) -> Option<&Block>

Source

pub fn get_latest_block_hash(&self) -> SaitoHash

Source

pub fn get_latest_block_id(&self) -> BlockId

Source

pub fn get_latest_unlocked_stake_block_id(&self) -> BlockId

Source

pub fn get_block_sync(&self, block_hash: &SaitoHash) -> Option<&Block>

Source

pub fn get_block(&self, block_hash: &SaitoHash) -> Option<&Block>

Source

pub fn get_mut_block(&mut self, block_hash: &SaitoHash) -> Option<&mut Block>

Source

pub fn is_block_indexed(&self, block_hash: SaitoHash) -> bool

Source

pub fn contains_block_hash_at_block_id( &self, block_id: u64, block_hash: SaitoHash, ) -> bool

Source

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

Source

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.

Source

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), )

Source

pub fn add_ghost_block( &mut self, id: u64, previous_block_hash: SaitoHash, ts: Timestamp, pre_hash: SaitoHash, gt: bool, hash: SaitoHash, )

Source

pub async fn reset(&mut self)

Source

pub async fn save(&self)

Source

pub fn get_utxoset_data(&self) -> HashMap<SaitoPublicKey, Currency>

Source

pub fn get_slips_for(&self, public_key: SaitoPublicKey) -> Vec<Slip>

Source

pub fn get_balance_snapshot( &self, keys: Vec<SaitoPublicKey>, configs: &(dyn Configuration + Send + Sync), ) -> BalanceSnapshot

Source

pub fn is_slip_unlocked(&self, utxo_key: &SaitoUTXOSetKey) -> bool

Source

pub fn set_safe_to_prune_transaction(&mut self, block_id: u64)

Source

pub fn calculate_current_supply(&self) -> Currency

Source

pub async fn check_total_supply( &mut self, configs: &(dyn Configuration + Send + Sync), )

Trait Implementations§

Source§

impl Debug for Blockchain

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more

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.

§

impl<T> Instrument for T

§

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

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

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.

§

impl<T> Pointable for T

§

const ALIGN: usize

The alignment of pointer.
§

type Init = T

The type for initializers.
§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
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 = Infallible

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

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

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.
§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

§

fn vzip(self) -> V

§

impl<T> WithSubscriber for T

§

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
§

fn with_current_subscriber(self) -> WithDispatch<Self>

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