pub struct BlockView { /* private fields */ }
Expand description
A readonly and immutable struct which includes Block
and its associated hashes.
Notice
This struct is not implement the trait Default
, use BlockBuilder
to construct it.
Implementations§
source§impl BlockView
impl BlockView
sourcepub fn new_advanced_builder() -> BlockBuilder
pub fn new_advanced_builder() -> BlockBuilder
Creates an empty advanced builder.
sourcepub fn as_advanced_builder(&self) -> BlockBuilder
pub fn as_advanced_builder(&self) -> BlockBuilder
Creates an advanced builder base on current data.
source§impl BlockView
impl BlockView
sourcepub fn data(&self) -> Block
pub fn data(&self) -> Block
Gets a clone of packed::Block
.
sourcepub fn uncle_hashes(&self) -> Byte32Vec
pub fn uncle_hashes(&self) -> Byte32Vec
Gets a clone of uncle_hashes
.
sourcepub fn tx_witness_hashes(&self) -> &[Byte32]
pub fn tx_witness_hashes(&self) -> &[Byte32]
Extracts a slice of tx_witness_hashes
.
sourcepub fn number(&self) -> BlockNumber
pub fn number(&self) -> BlockNumber
Gets header.raw.number
.
sourcepub fn compact_target(&self) -> u32
pub fn compact_target(&self) -> u32
Gets header.raw.compact_target
.
sourcepub fn epoch(&self) -> EpochNumberWithFraction
pub fn epoch(&self) -> EpochNumberWithFraction
Gets header.raw.epoch
.
sourcepub fn parent_hash(&self) -> Byte32
pub fn parent_hash(&self) -> Byte32
Gets header.raw.parent_hash
.
sourcepub fn transactions_root(&self) -> Byte32
pub fn transactions_root(&self) -> Byte32
Gets header.raw.transactions_root
.
sourcepub fn proposals_hash(&self) -> Byte32
pub fn proposals_hash(&self) -> Byte32
Gets header.raw.proposals_hash
.
sourcepub fn extra_hash(&self) -> Byte32
pub fn extra_hash(&self) -> Byte32
Gets header.raw.extra_hash
.
sourcepub fn difficulty(&self) -> U256
pub fn difficulty(&self) -> U256
Gets header.difficulty
.
sourcepub fn header(&self) -> HeaderView
pub fn header(&self) -> HeaderView
Gets header
.
sourcepub fn uncles(&self) -> UncleBlockVecView
pub fn uncles(&self) -> UncleBlockVecView
Gets uncles
.
sourcepub fn as_uncle(&self) -> UncleBlockView
pub fn as_uncle(&self) -> UncleBlockView
Converts into an uncle block.
sourcepub fn transactions(&self) -> Vec<TransactionView>
pub fn transactions(&self) -> Vec<TransactionView>
Gets transactions
.
sourcepub fn union_proposal_ids_iter(&self) -> impl Iterator<Item = ProposalShortId>
pub fn union_proposal_ids_iter(&self) -> impl Iterator<Item = ProposalShortId>
Creates an iterator from proposals
of the block and proposals
of uncles
.
sourcepub fn union_proposal_ids(&self) -> HashSet<ProposalShortId>
pub fn union_proposal_ids(&self) -> HashSet<ProposalShortId>
Creates a hashset from proposals
of the block and proposals
of uncles
.
sourcepub fn transaction(&self, index: usize) -> Option<TransactionView>
pub fn transaction(&self, index: usize) -> Option<TransactionView>
Gets a transaction through its index.
sourcepub fn output(&self, tx_index: usize, index: usize) -> Option<CellOutput>
pub fn output(&self, tx_index: usize, index: usize) -> Option<CellOutput>
Gets an output through its transaction index and its own index.
sourcepub fn is_genesis(&self) -> bool
pub fn is_genesis(&self) -> bool
Checks whether the block is the genesis block.
sourcepub fn calc_uncles_hash(&self) -> Byte32
pub fn calc_uncles_hash(&self) -> Byte32
Calculates the hash for uncle blocks.
sourcepub fn calc_extension_hash(&self) -> Option<Byte32>
pub fn calc_extension_hash(&self) -> Option<Byte32>
Calculates the hash for extension.
sourcepub fn calc_extra_hash(&self) -> ExtraHashView
pub fn calc_extra_hash(&self) -> ExtraHashView
Calculates the extra hash.
sourcepub fn calc_proposals_hash(&self) -> Byte32
pub fn calc_proposals_hash(&self) -> Byte32
Calculates the hash for proposals.
sourcepub fn calc_transactions_root(&self) -> Byte32
pub fn calc_transactions_root(&self) -> Byte32
Calculates the merkel root for transactions with witnesses.
sourcepub fn calc_raw_transactions_root(&self) -> Byte32
pub fn calc_raw_transactions_root(&self) -> Byte32
Calculates the merkle root for transactions without witnesses.
sourcepub fn calc_witnesses_root(&self) -> Byte32
pub fn calc_witnesses_root(&self) -> Byte32
Calculates the merkle root for transaction witnesses.