pub struct Block {
pub block_index: u64,
pub timestamp: u64,
pub previous_hash: String,
pub hash: String,
pub data: Value,
pub miner_address: String,
pub transactions: Vec<Transaction>,
}Expand description
This is the block struct.
It includes index, timestamp,
hash previous hash and data field.
Fields§
§block_index: u64§timestamp: u64§previous_hash: String§hash: String§data: Value§miner_address: String§transactions: Vec<Transaction>Implementations§
Source§impl Block
Functions for Struct Block.
impl Block
Functions for Struct Block.
Sourcepub fn new(
block_index: u64,
timestamp: u64,
previous_hash: String,
data: Value,
miner_address: String,
transactions: Vec<Transaction>,
) -> Block
pub fn new( block_index: u64, timestamp: u64, previous_hash: String, data: Value, miner_address: String, transactions: Vec<Transaction>, ) -> Block
Function to create a new block struct.
Sourcepub fn calculate_hash(&self) -> String
pub fn calculate_hash(&self) -> String
This function calculates the hash for the block.
The hash is SHA256.
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
Auto Trait Implementations§
impl Freeze for Block
impl RefUnwindSafe for Block
impl Send for Block
impl Sync for Block
impl Unpin 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