pub struct Block {
pub header: BlockHeader,
pub transactions: Vec<SignedTransaction>,
}Expand description
A complete block with header and transactions
Fields§
§header: BlockHeaderBlock header
transactions: Vec<SignedTransaction>List of transactions in this block
Implementations§
Source§impl Block
impl Block
Sourcepub fn new(header: BlockHeader, transactions: Vec<SignedTransaction>) -> Self
pub fn new(header: BlockHeader, transactions: Vec<SignedTransaction>) -> Self
Create a new block
Sourcepub fn genesis(
state_root: Hash,
proposer_pubkey: [u8; 32],
timestamp: Timestamp,
) -> Self
pub fn genesis( state_root: Hash, proposer_pubkey: [u8; 32], timestamp: Timestamp, ) -> Self
Create a genesis block
Sourcepub fn height(&self) -> BlockHeight
pub fn height(&self) -> BlockHeight
Get block height
Sourcepub fn compute_tx_root(&self) -> Hash
pub fn compute_tx_root(&self) -> Hash
Compute the transaction root from the block’s transactions
Sourcepub fn verify_tx_root(&self) -> bool
pub fn verify_tx_root(&self) -> bool
Verify that tx_root matches the transactions
Sourcepub fn from_bytes(bytes: &[u8]) -> Result<Self, Error>
pub fn from_bytes(bytes: &[u8]) -> Result<Self, Error>
Deserialize from bytes
Trait Implementations§
Source§impl<'de> Deserialize<'de> for Block
impl<'de> Deserialize<'de> for Block
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
Deserialize this value from the given Serde deserializer. Read more
impl Eq for Block
impl StructuralPartialEq for Block
Auto Trait Implementations§
impl Freeze for Block
impl RefUnwindSafe for Block
impl Send for Block
impl Sync for Block
impl Unpin for Block
impl UnsafeUnpin for Block
impl UnwindSafe for Block
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