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§
sourcefn load_initial_ledger(&mut self) -> Result<(), LedgerError>
fn load_initial_ledger(&mut self) -> Result<(), LedgerError>
Loads ledger from file
sourcefn get_balance(&self, addr: &Address) -> Option<Amount>
fn get_balance(&self, addr: &Address) -> Option<Amount>
sourcefn get_bytecode(&self, addr: &Address) -> Option<Bytecode>
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
sourcefn entry_exists(&self, addr: &Address) -> bool
fn entry_exists(&self, addr: &Address) -> bool
sourcefn 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 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 apply_changes_to_batch( &mut self, changes: LedgerChanges, ledger_batch: &mut DBBatch, )
sourcefn is_key_value_valid(
&self,
serialized_key: &[u8],
serialized_value: &[u8],
) -> bool
fn is_key_value_valid( &self, serialized_key: &[u8], serialized_value: &[u8], ) -> bool
Deserializes the key and value, useful after bootstrap