Struct miden_objects::accounts::StorageMap
source · pub struct StorageMap { /* private fields */ }Expand description
Account storage map is a Sparse Merkle Tree of depth 64. It can be used to store more data as there is in plain usage of the storage slots. The root of the SMT consumes one account storage slot.
Implementations§
source§impl StorageMap
impl StorageMap
sourcepub const STORAGE_MAP_TREE_DEPTH: u8 = 64u8
pub const STORAGE_MAP_TREE_DEPTH: u8 = 64u8
Depth of the storage tree.
sourcepub const EMPTY_VALUE: Word = Smt::EMPTY_VALUE
pub const EMPTY_VALUE: Word = Smt::EMPTY_VALUE
The default value of empty leaves.
sourcepub fn new() -> Self
pub fn new() -> Self
Returns a new StorageMap.
All leaves in the returned tree are set to Self::EMPTY_VALUE.
pub fn with_entries( entries: impl IntoIterator<Item = (RpoDigest, Word)>, ) -> Result<Self, AccountError>
pub const fn depth(&self) -> u8
pub fn root(&self) -> RpoDigest
pub fn get_leaf(&self, key: &RpoDigest) -> SmtLeaf
pub fn get_value(&self, key: &RpoDigest) -> Word
pub fn open(&self, key: &RpoDigest) -> SmtProof
pub fn leaves(&self) -> impl Iterator<Item = (LeafIndex<SMT_DEPTH>, &SmtLeaf)>
pub fn entries(&self) -> impl Iterator<Item = &(RpoDigest, Word)>
pub fn inner_nodes(&self) -> impl Iterator<Item = InnerNodeInfo> + '_
pub fn insert(&mut self, key: RpoDigest, value: Word) -> Word
sourcepub fn apply_delta(
&mut self,
delta: &StorageMapDelta,
) -> Result<Digest, AccountError>
pub fn apply_delta( &mut self, delta: &StorageMapDelta, ) -> Result<Digest, AccountError>
Applies the provided delta to this account storage.
This method assumes that the delta has been validated by the calling method and so, no additional validation of delta is performed.
Trait Implementations§
source§impl Clone for StorageMap
impl Clone for StorageMap
source§fn clone(&self) -> StorageMap
fn clone(&self) -> StorageMap
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 StorageMap
impl Debug for StorageMap
source§impl Default for StorageMap
impl Default for StorageMap
source§impl Deserializable for StorageMap
impl Deserializable for StorageMap
source§fn read_from<R: ByteReader>(
source: &mut R,
) -> Result<Self, DeserializationError>
fn read_from<R: ByteReader>( source: &mut R, ) -> Result<Self, DeserializationError>
Reads a sequence of bytes from the provided
source, attempts to deserialize these bytes
into Self, and returns the result. Read moresource§fn read_from_bytes(bytes: &[u8]) -> Result<Self, DeserializationError>
fn read_from_bytes(bytes: &[u8]) -> Result<Self, DeserializationError>
source§impl PartialEq for StorageMap
impl PartialEq for StorageMap
source§fn eq(&self, other: &StorageMap) -> bool
fn eq(&self, other: &StorageMap) -> bool
This method tests for
self and other values to be equal, and is used
by ==.source§impl Serializable for StorageMap
impl Serializable for StorageMap
source§fn write_into<W: ByteWriter>(&self, target: &mut W)
fn write_into<W: ByteWriter>(&self, target: &mut W)
Serializes
self into bytes and writes these bytes into the target.source§fn get_size_hint(&self) -> usize
fn get_size_hint(&self) -> usize
Returns an estimate of how many bytes are needed to represent self. Read more
impl Eq for StorageMap
impl StructuralPartialEq for StorageMap
Auto Trait Implementations§
impl Freeze for StorageMap
impl RefUnwindSafe for StorageMap
impl Send for StorageMap
impl Sync for StorageMap
impl Unpin for StorageMap
impl UnwindSafe for StorageMap
Blanket Implementations§
source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
source§default unsafe fn clone_to_uninit(&self, dst: *mut T)
default unsafe fn clone_to_uninit(&self, dst: *mut T)
🔬This is a nightly-only experimental API. (
clone_to_uninit)