[][src]Trait rchain_v1::rchain::WorldState

pub trait WorldState {
    fn get_user_ids(&self) -> Vec<String>;
fn get_account_by_id_mut(&mut self, id: &String) -> Option<&mut Account>;
fn get_account_by_id(&self, id: &String) -> Option<&Account>;
fn create_account(
        &mut self,
        id: String,
        account_type: AccountType
    ) -> Result<(), &'static str>; }

Represents the current state of the blockchain after all Blocks are executed A world state is technically not necessary since we always could build the information by iterating through all the blocks. Generally, this doesn't seem like a good option However, we do not force the actual Blockchain to implement a WorldState but rather behave like having one. This trait therefore just defines an expected interface into our Blockchain (Actually it doesn't even care if we the information is stored within a blockchain)

Required methods

fn get_user_ids(&self) -> Vec<String>

Will bring us all registered user ids

fn get_account_by_id_mut(&mut self, id: &String) -> Option<&mut Account>

Will return an account given it id if is available (mutable)

fn get_account_by_id(&self, id: &String) -> Option<&Account>

Will return an account given it id if is available

fn create_account(
    &mut self,
    id: String,
    account_type: AccountType
) -> Result<(), &'static str>

Will add a new account

Loading content...

Implementors

impl WorldState for Blockchain[src]

Loading content...