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§
source§impl MemoryStorage
impl MemoryStorage
sourcepub fn all_contract_state(
&self
) -> impl Iterator<Item = (&(ContractId, Bytes32), &Bytes32)>
pub fn all_contract_state(
&self
) -> impl Iterator<Item = (&(ContractId, Bytes32), &Bytes32)>
Iterate over all contract state in storage
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§
source§impl AsMut<MemoryStorage> for MemoryClient
impl AsMut<MemoryStorage> for MemoryClient
source§fn 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.
source§impl AsRef<MemoryStorage> for MemoryClient
impl AsRef<MemoryStorage> for MemoryClient
source§fn as_ref(&self) -> &MemoryStorage
fn as_ref(&self) -> &MemoryStorage
Converts this type into a shared reference of the (usually inferred) input type.
source§impl Clone for MemoryStorage
impl Clone for MemoryStorage
source§fn clone(&self) -> MemoryStorage
fn clone(&self) -> MemoryStorage
Returns a copy of the value. Read more
1.0.0 · source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source
. Read moresource§impl Debug for MemoryStorage
impl Debug for MemoryStorage
source§impl Default for MemoryStorage
impl Default for MemoryStorage
source§impl From<MemoryStorage> for MemoryClient
impl From<MemoryStorage> for MemoryClient
source§fn from(s: MemoryStorage) -> Self
fn from(s: MemoryStorage) -> Self
Converts to this type from the input type.
source§impl InterpreterStorage for MemoryStorage
impl InterpreterStorage for MemoryStorage
§type DataError = Infallible
type DataError = Infallible
Error implementation for reasons unspecified in the protocol.
source§fn 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
source§fn 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
source§fn 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.
source§fn coinbase(&self) -> Result<Address, Infallible>
fn coinbase(&self) -> Result<Address, Infallible>
Provide the coinbase address for the VM instructions implementation.
source§fn merkle_contract_state_range(
&self,
id: &ContractId,
start_key: &Bytes32,
range: Word
) -> Result<Vec<Option<Cow<'_, Bytes32>>>, Self::DataError>
fn merkle_contract_state_range(
&self,
id: &ContractId,
start_key: &Bytes32,
range: Word
) -> Result<Vec<Option<Cow<'_, Bytes32>>>, Self::DataError>
Fetch a range of values from a key-value mapping in a contract storage.
Returns the full range requested using optional values in case
a requested slot is unset. Read more
source§fn merkle_contract_state_insert_range(
&mut self,
contract: &ContractId,
start_key: &Bytes32,
values: &[Bytes32]
) -> Result<Option<()>, Self::DataError>
fn merkle_contract_state_insert_range(
&mut self,
contract: &ContractId,
start_key: &Bytes32,
values: &[Bytes32]
) -> Result<Option<()>, Self::DataError>
Insert a range of key-value mappings into contract storage.
Returns None if any of the keys in the range were previously unset. Read more
source§fn merkle_contract_state_remove_range(
&mut self,
contract: &ContractId,
start_key: &Bytes32,
range: Word
) -> Result<Option<()>, Self::DataError>
fn merkle_contract_state_remove_range(
&mut self,
contract: &ContractId,
start_key: &Bytes32,
range: Word
) -> Result<Option<()>, Self::DataError>
Remove a range of key-values from contract storage.
Returns None if any of the keys in the range were already unset. Read more
source§fn deploy_contract(
&mut self,
salt: &Salt,
slots: &[StorageSlot],
contract: &Contract
) -> Result<(), Self::DataError>
fn deploy_contract(
&mut self,
salt: &Salt,
slots: &[StorageSlot],
contract: &Contract
) -> Result<(), Self::DataError>
Deploy a contract into the storage
source§fn deploy_contract_with_id(
&mut self,
salt: &Salt,
slots: &[StorageSlot],
contract: &Contract,
root: &Bytes32,
id: &ContractId
) -> Result<(), Self::DataError>
fn deploy_contract_with_id(
&mut self,
salt: &Salt,
slots: &[StorageSlot],
contract: &Contract,
root: &Bytes32,
id: &ContractId
) -> Result<(), Self::DataError>
Deploy a contract into the storage with contract id
source§fn 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
source§fn 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
source§fn 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.
source§fn 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
source§fn 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.
source§fn 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.
source§fn 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.
source§fn merkle_contract_state_remove(
&mut self,
contract: &ContractId,
key: &Bytes32
) -> Result<Option<Bytes32>, Self::DataError>
fn merkle_contract_state_remove(
&mut self,
contract: &ContractId,
key: &Bytes32
) -> Result<Option<Bytes32>, Self::DataError>
Remove a key-value mapping from a contract storage.
source§fn 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.
source§fn 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.
source§impl MerkleRootStorage<ContractId, ContractsAssets<'_>> for MemoryStorage
impl MerkleRootStorage<ContractId, ContractsAssets<'_>> for MemoryStorage
source§fn root(&mut self, parent: &ContractId) -> Result<MerkleRoot, Infallible>
fn root(&mut self, parent: &ContractId) -> Result<MerkleRoot, Infallible>
Return the merkle root of the stored
Type
in the storage. Read moresource§impl MerkleRootStorage<ContractId, ContractsState<'_>> for MemoryStorage
impl MerkleRootStorage<ContractId, ContractsState<'_>> for MemoryStorage
source§fn root(&mut self, parent: &ContractId) -> Result<MerkleRoot, Infallible>
fn root(&mut self, parent: &ContractId) -> Result<MerkleRoot, Infallible>
Return the merkle root of the stored
Type
in the storage. Read moresource§impl StorageInspect<ContractsAssets<'_>> for MemoryStorage
impl StorageInspect<ContractsAssets<'_>> for MemoryStorage
type Error = Infallible
source§fn get(
&self,
key: &(&ContractId, &AssetId)
) -> Result<Option<Cow<'_, Word>>, Infallible>
fn get(
&self,
key: &(&ContractId, &AssetId)
) -> Result<Option<Cow<'_, Word>>, Infallible>
Retrieve
Cow<Value>
such as Key->Value
.source§fn contains_key(&self, key: &(&ContractId, &AssetId)) -> Result<bool, Infallible>
fn contains_key(&self, key: &(&ContractId, &AssetId)) -> Result<bool, Infallible>
Return
true
if there is a Key
mapping to a value in the storage.source§impl StorageInspect<ContractsInfo> for MemoryStorage
impl StorageInspect<ContractsInfo> for MemoryStorage
type Error = Infallible
source§fn get(
&self,
key: &ContractId
) -> Result<Option<Cow<'_, (Salt, Bytes32)>>, Infallible>
fn get(
&self,
key: &ContractId
) -> Result<Option<Cow<'_, (Salt, Bytes32)>>, Infallible>
Retrieve
Cow<Value>
such as Key->Value
.source§fn contains_key(&self, key: &ContractId) -> Result<bool, Infallible>
fn contains_key(&self, key: &ContractId) -> Result<bool, Infallible>
Return
true
if there is a Key
mapping to a value in the storage.source§impl StorageInspect<ContractsRawCode> for MemoryStorage
impl StorageInspect<ContractsRawCode> for MemoryStorage
type Error = Infallible
source§fn get(&self, key: &ContractId) -> Result<Option<Cow<'_, Contract>>, Infallible>
fn get(&self, key: &ContractId) -> Result<Option<Cow<'_, Contract>>, Infallible>
Retrieve
Cow<Value>
such as Key->Value
.source§fn contains_key(&self, key: &ContractId) -> Result<bool, Infallible>
fn contains_key(&self, key: &ContractId) -> Result<bool, Infallible>
Return
true
if there is a Key
mapping to a value in the storage.source§impl StorageInspect<ContractsState<'_>> for MemoryStorage
impl StorageInspect<ContractsState<'_>> for MemoryStorage
type Error = Infallible
source§fn get(
&self,
key: &(&ContractId, &Bytes32)
) -> Result<Option<Cow<'_, Bytes32>>, Infallible>
fn get(
&self,
key: &(&ContractId, &Bytes32)
) -> Result<Option<Cow<'_, Bytes32>>, Infallible>
Retrieve
Cow<Value>
such as Key->Value
.source§fn contains_key(&self, key: &(&ContractId, &Bytes32)) -> Result<bool, Infallible>
fn contains_key(&self, key: &(&ContractId, &Bytes32)) -> Result<bool, Infallible>
Return
true
if there is a Key
mapping to a value in the storage.source§impl StorageMutate<ContractsAssets<'_>> for MemoryStorage
impl StorageMutate<ContractsAssets<'_>> for MemoryStorage
source§fn insert(
&mut self,
key: &(&ContractId, &AssetId),
value: &Word
) -> Result<Option<Word>, Infallible>
fn insert(
&mut self,
key: &(&ContractId, &AssetId),
value: &Word
) -> Result<Option<Word>, Infallible>
Append
Key->Value
mapping to the storage. Read moresource§fn remove(
&mut self,
key: &(&ContractId, &AssetId)
) -> Result<Option<Word>, Infallible>
fn remove(
&mut self,
key: &(&ContractId, &AssetId)
) -> Result<Option<Word>, Infallible>
Remove
Key->Value
mapping from the storage. Read moresource§impl StorageMutate<ContractsInfo> for MemoryStorage
impl StorageMutate<ContractsInfo> for MemoryStorage
source§fn 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
Key->Value
mapping to the storage. Read moresource§fn remove(
&mut self,
key: &ContractId
) -> Result<Option<(Salt, Bytes32)>, Infallible>
fn remove(
&mut self,
key: &ContractId
) -> Result<Option<(Salt, Bytes32)>, Infallible>
Remove
Key->Value
mapping from the storage. Read moresource§impl StorageMutate<ContractsRawCode> for MemoryStorage
impl StorageMutate<ContractsRawCode> for MemoryStorage
source§fn insert(
&mut self,
key: &ContractId,
value: &[u8]
) -> Result<Option<Contract>, Infallible>
fn insert(
&mut self,
key: &ContractId,
value: &[u8]
) -> Result<Option<Contract>, Infallible>
Append
Key->Value
mapping to the storage. Read moresource§fn remove(&mut self, key: &ContractId) -> Result<Option<Contract>, Infallible>
fn remove(&mut self, key: &ContractId) -> Result<Option<Contract>, Infallible>
Remove
Key->Value
mapping from the storage. Read moresource§impl StorageMutate<ContractsState<'_>> for MemoryStorage
impl StorageMutate<ContractsState<'_>> for MemoryStorage
source§fn insert(
&mut self,
key: &(&ContractId, &Bytes32),
value: &Bytes32
) -> Result<Option<Bytes32>, Infallible>
fn insert(
&mut self,
key: &(&ContractId, &Bytes32),
value: &Bytes32
) -> Result<Option<Bytes32>, Infallible>
Append
Key->Value
mapping to the storage. Read moresource§fn remove(
&mut self,
key: &(&ContractId, &Bytes32)
) -> Result<Option<Bytes32>, Infallible>
fn remove(
&mut self,
key: &(&ContractId, &Bytes32)
) -> Result<Option<Bytes32>, Infallible>
Remove
Key->Value
mapping from the storage. Read more