[][src]Struct rchain_v1::rchain::Block

pub struct Block {
    pub(crate) transactions: Vec<Transaction>,
    prev_hash: Option<String>,
    hash: Option<String>,
    nonce: u128,
}

One single part of the blockchain. Basically contains a list of transactions

Fields

transactions: Vec<Transaction>

Actions that this block includes There has to be at least one

prev_hash: Option<String>

This actually connects the blocks together

hash: Option<String>

We store the hash of the block here also in order to save the last block from being tampered with later on

nonce: u128

Some arbitrary number which will be later used for Proof of Work

Methods

impl Block[src]

pub fn new(prev_hash: Option<String>) -> Self[src]

pub fn set_nonce(&mut self, nonce: u128)[src]

Changes the nonce number and updates the hash

pub fn calculate_hash(&self) -> Vec<u8>[src]

Will calculate the hash of the whole block including transactions Blake2 hasher

pub fn add_transaction(&mut self, transaction: Transaction)[src]

Appends a transaction to the queue

pub fn get_transaction_count(&self) -> usize[src]

Will return the amount of transactions

pub(crate) fn update_hash(&mut self)[src]

Will update the hash field by including all transactions currently inside the public modifier is only for the demonstration of attacks

pub fn verify_own_hash(&self) -> bool[src]

Checks if the hash is set and matches the blocks interna

Trait Implementations

impl Clone for Block[src]

impl Debug for Block[src]

Auto Trait Implementations

impl RefUnwindSafe for Block

impl Send for Block

impl Sync for Block

impl Unpin for Block

impl UnwindSafe for Block

Blanket Implementations

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> From<T> for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T> Same<T> for T

type Output = T

Should always be Self

impl<T> ToOwned for T where
    T: Clone
[src]

type Owned = T

The resulting type after obtaining ownership.

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.