Trait massa_ledger_exports::LedgerController

source ·
pub trait LedgerController: Send + Sync {
    // Required methods
    fn load_initial_ledger(&mut self) -> Result<(), LedgerError>;
    fn get_balance(&self, addr: &Address) -> Option<Amount>;
    fn get_bytecode(&self, addr: &Address) -> Option<Bytecode>;
    fn entry_exists(&self, addr: &Address) -> bool;
    fn get_data_entry(&self, addr: &Address, key: &[u8]) -> Option<Vec<u8>>;
    fn get_datastore_keys(
        &self,
        addr: &Address,
        prefix: &[u8],
        start_key: Bound<Vec<u8>>,
        end_key: Bound<Vec<u8>>,
        count: Option<u32>,
    ) -> Option<BTreeSet<Vec<u8>>>;
    fn reset(&mut self);
    fn apply_changes_to_batch(
        &mut self,
        changes: LedgerChanges,
        ledger_batch: &mut DBBatch,
    );
    fn is_key_value_valid(
        &self,
        serialized_key: &[u8],
        serialized_value: &[u8],
    ) -> bool;
}

Required Methods§

source

fn load_initial_ledger(&mut self) -> Result<(), LedgerError>

Loads ledger from file

source

fn get_balance(&self, addr: &Address) -> Option<Amount>

Gets the balance of a ledger entry

§Returns

The balance, or None if the ledger entry was not found

source

fn get_bytecode(&self, addr: &Address) -> Option<Bytecode>

Gets a copy of the bytecode of a ledger entry

§Returns

A copy of the found bytecode, or None if the ledger entry was not found

source

fn entry_exists(&self, addr: &Address) -> bool

Checks if a ledger entry exists

§Returns

true if it exists, false otherwise.

source

fn get_data_entry(&self, addr: &Address, key: &[u8]) -> Option<Vec<u8>>

Gets a copy of the value of a datastore entry for a given address.

§Arguments
  • addr: target address
  • key: datastore key
§Returns

A copy of the datastore value, or None if the ledger entry or datastore entry was not found

source

fn get_datastore_keys( &self, addr: &Address, prefix: &[u8], start_key: Bound<Vec<u8>>, end_key: Bound<Vec<u8>>, count: Option<u32>, ) -> Option<BTreeSet<Vec<u8>>>

Get every key of the datastore for a given address.

§Returns

A BTreeSet of the datastore keys

source

fn reset(&mut self)

Reset the ledger

USED FOR BOOTSTRAP ONLY

source

fn apply_changes_to_batch( &mut self, changes: LedgerChanges, ledger_batch: &mut DBBatch, )

source

fn is_key_value_valid( &self, serialized_key: &[u8], serialized_value: &[u8], ) -> bool

Deserializes the key and value, useful after bootstrap

Implementors§