[−][src]Struct rchain_v1::rchain::Block
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
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]
T: 'static + ?Sized,
impl<T> Borrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
T: ?Sized,
fn borrow_mut(&mut self) -> &mut T
[src]
impl<T> From<T> for T
[src]
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
impl<T> Same<T> for T
type Output = T
Should always be Self
impl<T> ToOwned for T where
T: Clone,
[src]
T: Clone,
type Owned = T
The resulting type after obtaining ownership.
fn to_owned(&self) -> T
[src]
fn clone_into(&self, target: &mut T)
[src]
impl<T, U> TryFrom<U> for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,