Trait diem_state_view::StateView
source · pub trait StateView: Sync {
// Required methods
fn get(&self, access_path: &AccessPath) -> Result<Option<Vec<u8>>>;
fn multi_get(
&self,
access_paths: &[AccessPath]
) -> Result<Vec<Option<Vec<u8>>>>;
fn is_genesis(&self) -> bool;
fn pos_state(&self) -> &PosState;
// Provided method
fn id(&self) -> StateViewId { ... }
}
Expand description
StateView
is a trait that defines a read-only snapshot of the global
state. It is passed to the VM for transaction execution, during which the VM
is guaranteed to read anything at the given state.
Required Methods§
sourcefn get(&self, access_path: &AccessPath) -> Result<Option<Vec<u8>>>
fn get(&self, access_path: &AccessPath) -> Result<Option<Vec<u8>>>
Gets the state for a single access path.
sourcefn multi_get(&self, access_paths: &[AccessPath]) -> Result<Vec<Option<Vec<u8>>>>
fn multi_get(&self, access_paths: &[AccessPath]) -> Result<Vec<Option<Vec<u8>>>>
Gets states for a list of access paths.
sourcefn is_genesis(&self) -> bool
fn is_genesis(&self) -> bool
VM needs this method to know whether the current state view is for genesis state creation. Currently TransactionPayload::WriteSet is only valid for genesis state creation.
fn pos_state(&self) -> &PosState
Provided Methods§
sourcefn id(&self) -> StateViewId
fn id(&self) -> StateViewId
For logging and debugging purpose, identifies what this view is for.