Struct fuel_vm::storage::MemoryStorage
source · [−]pub struct MemoryStorage { /* private fields */ }
Expand description
In-memory storage implementation for the interpreter.
It tracks 3 states:
- memory: the transactions will be applied to this state.
- transacted: will receive the committed
memory
state. - persisted: will receive the persisted
transacted
state.
Implementations
sourceimpl MemoryStorage
impl MemoryStorage
sourcepub fn contract_state(
&self,
contract: &ContractId,
key: &Bytes32
) -> Cow<'_, Bytes32>
pub fn contract_state(
&self,
contract: &ContractId,
key: &Bytes32
) -> Cow<'_, Bytes32>
Fetch a mapping from the contract state.
Trait Implementations
sourceimpl<'a> AsMut<MemoryStorage> for MemoryClient<'a>
impl<'a> AsMut<MemoryStorage> for MemoryClient<'a>
sourcefn as_mut(&mut self) -> &mut MemoryStorage
fn as_mut(&mut self) -> &mut MemoryStorage
Converts this type into a mutable reference of the (usually inferred) input type.
sourceimpl<'a> AsRef<MemoryStorage> for MemoryClient<'a>
impl<'a> AsRef<MemoryStorage> for MemoryClient<'a>
sourcefn as_ref(&self) -> &MemoryStorage
fn as_ref(&self) -> &MemoryStorage
Converts this type into a shared reference of the (usually inferred) input type.
sourceimpl Clone for MemoryStorage
impl Clone for MemoryStorage
sourcefn clone(&self) -> MemoryStorage
fn clone(&self) -> MemoryStorage
Returns a copy of the value. Read more
1.0.0 · sourcefn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from source
. Read more
sourceimpl Debug for MemoryStorage
impl Debug for MemoryStorage
sourceimpl Default for MemoryStorage
impl Default for MemoryStorage
sourceimpl<'a> From<MemoryStorage> for MemoryClient<'a>
impl<'a> From<MemoryStorage> for MemoryClient<'a>
sourcefn from(s: MemoryStorage) -> Self
fn from(s: MemoryStorage) -> Self
Converts to this type from the input type.
sourceimpl InterpreterStorage for MemoryStorage
impl InterpreterStorage for MemoryStorage
type DataError = Infallible
type DataError = Infallible
Error implementation for reasons unspecified in the protocol.
sourcefn block_height(&self) -> Result<u32, Infallible>
fn block_height(&self) -> Result<u32, Infallible>
Provide the current block height in which the transactions should be executed. Read more
sourcefn timestamp(&self, height: u32) -> Result<Word, Self::DataError>
fn timestamp(&self, height: u32) -> Result<Word, Self::DataError>
Return the timestamp of a given block Read more
sourcefn block_hash(&self, block_height: u32) -> Result<Bytes32, Infallible>
fn block_hash(&self, block_height: u32) -> Result<Bytes32, Infallible>
Provide the block hash from a given height.
sourcefn coinbase(&self) -> Result<Address, Infallible>
fn coinbase(&self) -> Result<Address, Infallible>
Provide the coinbase address for the VM instructions implementation.
sourcefn storage_contract(
&self,
id: &ContractId
) -> Result<Option<Cow<'_, Contract>>, Self::DataError>
fn storage_contract(
&self,
id: &ContractId
) -> Result<Option<Cow<'_, Contract>>, Self::DataError>
Fetch a previously inserted contract code from the chain state for a given contract. Read more
sourcefn storage_contract_insert(
&mut self,
id: &ContractId,
contract: &Contract
) -> Result<Option<Contract>, Self::DataError>
fn storage_contract_insert(
&mut self,
id: &ContractId,
contract: &Contract
) -> Result<Option<Contract>, Self::DataError>
Append a contract to the chain, provided its identifier. Read more
sourcefn storage_contract_exists(
&self,
id: &ContractId
) -> Result<bool, Self::DataError>
fn storage_contract_exists(
&self,
id: &ContractId
) -> Result<bool, Self::DataError>
Check if a provided contract exists in the chain.
sourcefn storage_contract_root(
&self,
id: &ContractId
) -> Result<Option<Cow<'_, (Salt, Bytes32)>>, Self::DataError>
fn storage_contract_root(
&self,
id: &ContractId
) -> Result<Option<Cow<'_, (Salt, Bytes32)>>, Self::DataError>
Fetch a previously inserted salt+root tuple from the chain state for a given contract. Read more
sourcefn storage_contract_root_insert(
&mut self,
id: &ContractId,
salt: &Salt,
root: &Bytes32
) -> Result<Option<(Salt, Bytes32)>, Self::DataError>
fn storage_contract_root_insert(
&mut self,
id: &ContractId,
salt: &Salt,
root: &Bytes32
) -> Result<Option<(Salt, Bytes32)>, Self::DataError>
Append the salt+root of a contract that was appended to the chain.
sourcefn merkle_contract_state(
&self,
id: &ContractId,
key: &Bytes32
) -> Result<Option<Cow<'_, Bytes32>>, Self::DataError>
fn merkle_contract_state(
&self,
id: &ContractId,
key: &Bytes32
) -> Result<Option<Cow<'_, Bytes32>>, Self::DataError>
Fetch the value form a key-value mapping in a contract storage.
sourcefn merkle_contract_state_insert(
&mut self,
contract: &ContractId,
key: &Bytes32,
value: &Bytes32
) -> Result<Option<Bytes32>, Self::DataError>
fn merkle_contract_state_insert(
&mut self,
contract: &ContractId,
key: &Bytes32,
value: &Bytes32
) -> Result<Option<Bytes32>, Self::DataError>
Insert a key-value mapping in a contract storage.
sourcefn merkle_contract_asset_id_balance(
&self,
id: &ContractId,
asset_id: &AssetId
) -> Result<Option<Word>, Self::DataError>
fn merkle_contract_asset_id_balance(
&self,
id: &ContractId,
asset_id: &AssetId
) -> Result<Option<Word>, Self::DataError>
Fetch the balance of an asset ID in a contract storage.
sourcefn merkle_contract_asset_id_balance_insert(
&mut self,
contract: &ContractId,
asset_id: &AssetId,
value: Word
) -> Result<Option<Word>, Self::DataError>
fn merkle_contract_asset_id_balance_insert(
&mut self,
contract: &ContractId,
asset_id: &AssetId,
value: Word
) -> Result<Option<Word>, Self::DataError>
Update the balance of an asset ID in a contract storage.
sourceimpl MerkleStorage<ContractId, AssetId, u64> for MemoryStorage
impl MerkleStorage<ContractId, AssetId, u64> for MemoryStorage
type Error = Infallible
type Error = Infallible
Error implementation of the merkle storage functions
sourcefn insert(
&mut self,
parent: &ContractId,
key: &AssetId,
value: &Word
) -> Result<Option<Word>, Infallible>
fn insert(
&mut self,
parent: &ContractId,
key: &AssetId,
value: &Word
) -> Result<Option<Word>, Infallible>
Append P->K->V
mapping to the storage. Read more
sourcefn get(
&self,
parent: &ContractId,
key: &AssetId
) -> Result<Option<Cow<'_, Word>>, Infallible>
fn get(
&self,
parent: &ContractId,
key: &AssetId
) -> Result<Option<Cow<'_, Word>>, Infallible>
Retrieve Cow<V>
such as P->K->V
.
sourcefn remove(
&mut self,
parent: &ContractId,
key: &AssetId
) -> Result<Option<Word>, Infallible>
fn remove(
&mut self,
parent: &ContractId,
key: &AssetId
) -> Result<Option<Word>, Infallible>
Remove P->K->V
mapping from the storage. Read more
sourcefn contains_key(
&self,
parent: &ContractId,
key: &AssetId
) -> Result<bool, Infallible>
fn contains_key(
&self,
parent: &ContractId,
key: &AssetId
) -> Result<bool, Infallible>
Return true
if there is a P->K
mapping to a value in the storage.
sourcefn root(&mut self, parent: &ContractId) -> Result<MerkleRoot, Infallible>
fn root(&mut self, parent: &ContractId) -> Result<MerkleRoot, Infallible>
Return the merkle root of the domain of P
. Read more
sourceimpl MerkleStorage<ContractId, Bytes32, Bytes32> for MemoryStorage
impl MerkleStorage<ContractId, Bytes32, Bytes32> for MemoryStorage
type Error = Infallible
type Error = Infallible
Error implementation of the merkle storage functions
sourcefn insert(
&mut self,
parent: &ContractId,
key: &Bytes32,
value: &Bytes32
) -> Result<Option<Bytes32>, Infallible>
fn insert(
&mut self,
parent: &ContractId,
key: &Bytes32,
value: &Bytes32
) -> Result<Option<Bytes32>, Infallible>
Append P->K->V
mapping to the storage. Read more
sourcefn get(
&self,
parent: &ContractId,
key: &Bytes32
) -> Result<Option<Cow<'_, Bytes32>>, Infallible>
fn get(
&self,
parent: &ContractId,
key: &Bytes32
) -> Result<Option<Cow<'_, Bytes32>>, Infallible>
Retrieve Cow<V>
such as P->K->V
.
sourcefn remove(
&mut self,
parent: &ContractId,
key: &Bytes32
) -> Result<Option<Bytes32>, Infallible>
fn remove(
&mut self,
parent: &ContractId,
key: &Bytes32
) -> Result<Option<Bytes32>, Infallible>
Remove P->K->V
mapping from the storage. Read more
sourcefn contains_key(
&self,
parent: &ContractId,
key: &Bytes32
) -> Result<bool, Infallible>
fn contains_key(
&self,
parent: &ContractId,
key: &Bytes32
) -> Result<bool, Infallible>
Return true
if there is a P->K
mapping to a value in the storage.
sourcefn root(&mut self, parent: &ContractId) -> Result<MerkleRoot, Infallible>
fn root(&mut self, parent: &ContractId) -> Result<MerkleRoot, Infallible>
Return the merkle root of the domain of P
. Read more
sourceimpl Storage<ContractId, (Salt, Bytes32)> for MemoryStorage
impl Storage<ContractId, (Salt, Bytes32)> for MemoryStorage
type Error = Infallible
type Error = Infallible
Error implementation of the storage functions
sourcefn insert(
&mut self,
key: &ContractId,
value: &(Salt, Bytes32)
) -> Result<Option<(Salt, Bytes32)>, Infallible>
fn insert(
&mut self,
key: &ContractId,
value: &(Salt, Bytes32)
) -> Result<Option<(Salt, Bytes32)>, Infallible>
Append K->V
mapping to the storage. Read more
sourcefn remove(
&mut self,
key: &ContractId
) -> Result<Option<(Salt, Bytes32)>, Infallible>
fn remove(
&mut self,
key: &ContractId
) -> Result<Option<(Salt, Bytes32)>, Infallible>
Remove K->V
mapping from the storage. Read more
sourcefn get(
&self,
key: &ContractId
) -> Result<Option<Cow<'_, (Salt, Bytes32)>>, Infallible>
fn get(
&self,
key: &ContractId
) -> Result<Option<Cow<'_, (Salt, Bytes32)>>, Infallible>
Retrieve Cow<V>
such as K->V
.
sourcefn contains_key(&self, key: &ContractId) -> Result<bool, Infallible>
fn contains_key(&self, key: &ContractId) -> Result<bool, Infallible>
Return true
if there is a K
mapping to a value in the storage.
sourceimpl Storage<ContractId, Contract> for MemoryStorage
impl Storage<ContractId, Contract> for MemoryStorage
type Error = Infallible
type Error = Infallible
Error implementation of the storage functions
sourcefn insert(
&mut self,
key: &ContractId,
value: &Contract
) -> Result<Option<Contract>, Infallible>
fn insert(
&mut self,
key: &ContractId,
value: &Contract
) -> Result<Option<Contract>, Infallible>
Append K->V
mapping to the storage. Read more
sourcefn remove(&mut self, key: &ContractId) -> Result<Option<Contract>, Infallible>
fn remove(&mut self, key: &ContractId) -> Result<Option<Contract>, Infallible>
Remove K->V
mapping from the storage. Read more
sourcefn get(&self, key: &ContractId) -> Result<Option<Cow<'_, Contract>>, Infallible>
fn get(&self, key: &ContractId) -> Result<Option<Cow<'_, Contract>>, Infallible>
Retrieve Cow<V>
such as K->V
.
sourcefn contains_key(&self, key: &ContractId) -> Result<bool, Infallible>
fn contains_key(&self, key: &ContractId) -> Result<bool, Infallible>
Return true
if there is a K
mapping to a value in the storage.
Auto Trait Implementations
impl RefUnwindSafe for MemoryStorage
impl Send for MemoryStorage
impl Sync for MemoryStorage
impl Unpin for MemoryStorage
impl UnwindSafe for MemoryStorage
Blanket Implementations
sourceimpl<T> BorrowMut<T> for T where
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
const: unstable · sourcefn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more