Struct disarray_ledger::blockchains::Blockchain
source · pub struct Blockchain {
pub chain: HashMap<H256, BlockData>,
pub epoch: Epoch,
pub lead: u128,
pub length: u128,
pub map: HashMap<H256, HashMap<H256, H160>>,
pub position: Position,
pub timestamp: i64,
pub tip: H256,
}
Fields
chain: HashMap<H256, BlockData>
epoch: Epoch
lead: u128
length: u128
map: HashMap<H256, HashMap<H256, H160>>
position: Position
timestamp: i64
tip: H256
Implementations
sourceimpl Blockchain
impl Blockchain
pub fn new(timestamp: i64) -> Self
pub fn insert_selfish_pos(&mut self, block: &Block) -> bool
pub fn insert_unselfish_pos(&mut self, block: &Block) -> bool
sourcepub fn insert_pos(&mut self, block: &Block, selfish: bool) -> bool
pub fn insert_pos(&mut self, block: &Block, selfish: bool) -> bool
General access for inserting new blocks created from staking
sourcepub fn insert_pow(&mut self, block: &Block) -> bool
pub fn insert_pow(&mut self, block: &Block) -> bool
Insert a PoW block into blockchain
Trait Implementations
sourceimpl ChainWrapper for Blockchain
impl ChainWrapper for Blockchain
fn chain_fetch<T>(
&self,
data: &H256,
catalyst: fn(_: &BlockData) -> T
) -> Option<T>
fn chain_size(&self) -> usize
fn contains_hash(&self, hash: &H256) -> bool
fn depth(&self) -> u128
fn epoch_current(&self, current_ts: BlockTs) -> BlockTs
fn position_pos(&self) -> u128
fn position_pow(&self) -> u128
sourceimpl ChainWrapperExt for Blockchain
impl ChainWrapperExt for Blockchain
sourcefn genesis(blockgen: fn(_: i64) -> Block, timestamp: i64) -> Selfwhere
Self: Sized,
fn genesis(blockgen: fn(_: i64) -> Block, timestamp: i64) -> Selfwhere
Self: Sized,
Create a new blockchain
fn find_one_block(&self, hash: &H256) -> Option<Block>
fn find_one_depth(&self, hash: &H256) -> Option<u128>
fn find_one_header(&self, hash: &H256) -> Option<BlockHeader>
fn find_one_height(&self, height: u128) -> H256
fn find_one_payload(&self, hash: &H256) -> Option<BlockData>
sourcefn get_chain_quality(&self) -> f32
fn get_chain_quality(&self) -> f32
TODO: Finalize the chain quality
fn get_all_blocks_from_longest(&self) -> Vec<H256>ⓘ
fn get_longest_chain(&self) -> Vec<Block>ⓘ
fn get_pos_difficulty(&self) -> H256
fn get_pow_difficulty(&self, current_ts: BlockTs, parent: H256) -> H256
fn is_new_epoch_and_count_blocks(
&self,
current_ts: BlockTs
) -> Option<HashMap<Vec<u8>, HashSet<H256>>>
fn print_longest_chain(&self)
sourceimpl CoreChainSpec for Blockchain
impl CoreChainSpec for Blockchain
sourceimpl Debug for Blockchain
impl Debug for Blockchain
sourceimpl Default for Blockchain
impl Default for Blockchain
Auto Trait Implementations
impl RefUnwindSafe for Blockchain
impl Send for Blockchain
impl Sync for Blockchain
impl Unpin for Blockchain
impl UnwindSafe for Blockchain
Blanket Implementations
sourceimpl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
const: unstable · sourcefn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more