[][src]Struct rchain_v1::rchain::Blockchain

pub struct Blockchain {
    pub blocks: Vec<Block>,
    pub accounts: HashMap<String, Account>,
    pending_transactions: Vec<Transaction>,
}

The actual Blockchain container

Fields

blocks: Vec<Block>

Stores all the blocks which are accepted already within the blockchain

accounts: HashMap<String, Account>

Lookup from AccountID (will be a public key later) to Account. Effectively, this represents the WorldState

pending_transactions: Vec<Transaction>

Will store transactions which should be added to the chain but aren't yet

Methods

impl Blockchain[src]

pub fn new() -> Self[src]

Constructor

pub fn append_block(&mut self, block: Block) -> Result<(), String>[src]

Will add a block to the Blockchain @TODO every simple step could be refactored into a separate function for better testability and code-reusability

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

Will return the amount of blocks currently stored

pub fn get_last_block_hash(&self) -> Option<String>[src]

Will return the hash of the last block

pub fn check_validity(&self) -> Result<(), String>[src]

Checks if the blockchain was tempered with It will check until the first error happens and return a description of the problem if everything is fine it will return Ok

Trait Implementations

impl Clone for Blockchain[src]

impl Debug for Blockchain[src]

impl WorldState for Blockchain[src]

Auto Trait Implementations

impl RefUnwindSafe for Blockchain

impl Send for Blockchain

impl Sync for Blockchain

impl Unpin for Blockchain

impl UnwindSafe for Blockchain

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.