pub trait DataStore {
    // Required methods
    fn load_resource(
        &mut self,
        addr: AccountAddress,
        ty: &Type
    ) -> PartialVMResult<&mut GlobalValue>;
    fn load_module(&self, module_id: &ModuleId) -> VMResult<Vec<u8>>;
    fn publish_module(
        &mut self,
        module_id: &ModuleId,
        blob: Vec<u8>
    ) -> VMResult<()>;
    fn exists_module(&self, module_id: &ModuleId) -> VMResult<bool>;
    fn emit_event(
        &mut self,
        guid: Vec<u8>,
        seq_num: u64,
        ty: Type,
        val: Value
    ) -> PartialVMResult<()>;
}
Expand description

Provide an implementation for bytecodes related to data with a given data store.

The DataStore is a generic concept that includes both data and events. A default implementation of the DataStore is TransactionDataCache which provides an in memory cache for a given transaction and the atomic transactional changes proper of a script execution (transaction).

Required Methods§

source

fn load_resource( &mut self, addr: AccountAddress, ty: &Type ) -> PartialVMResult<&mut GlobalValue>

Try to load a resource from remote storage and create a corresponding GlobalValue that is owned by the data store.

source

fn load_module(&self, module_id: &ModuleId) -> VMResult<Vec<u8>>

Get the serialized format of a CompiledModule given a ModuleId.

source

fn publish_module(&mut self, module_id: &ModuleId, blob: Vec<u8>) -> VMResult<()>

Publish a module.

source

fn exists_module(&self, module_id: &ModuleId) -> VMResult<bool>

Check if this module exists.

source

fn emit_event( &mut self, guid: Vec<u8>, seq_num: u64, ty: Type, val: Value ) -> PartialVMResult<()>

Emit an event to the EventStore

Implementors§