Struct cfx_storage::MemOptimizedTrieNode
source · pub struct MemOptimizedTrieNode<CacheAlgoDataT: CacheAlgoDataTrait> { /* private fields */ }
Expand description
A node consists of an optional compressed path (concept of Patricia Trie), an optional ChildrenTable (if the node is intermediate), an optional value attached, and the Merkle hash for subtree.
Implementations§
source§impl<CacheAlgoDataT: CacheAlgoDataTrait> MemOptimizedTrieNode<CacheAlgoDataT>
impl<CacheAlgoDataT: CacheAlgoDataTrait> MemOptimizedTrieNode<CacheAlgoDataT>
pub fn get_compressed_path_size(&self) -> u16
pub fn copy_compressed_path<CompressedPath: CompressedPathTrait>( &mut self, new_path: CompressedPath )
pub fn value_clone(&self) -> MptValue<Box<[u8]>>
pub fn check_value_size(value: &[u8]) -> Result<()>
pub fn check_key_size(access_key: &[u8]) -> Result<()>
source§impl<CacheAlgoDataT: CacheAlgoDataTrait> MemOptimizedTrieNode<CacheAlgoDataT>
impl<CacheAlgoDataT: CacheAlgoDataTrait> MemOptimizedTrieNode<CacheAlgoDataT>
The actual TrieNode type used in DeltaMpt. We’d like to keep as many of them as possible in memory.
pub fn new( merkle: MerkleHash, children_table: ChildrenTableDeltaMpt, maybe_value: Option<Box<[u8]>>, compressed_path: CompressedPathRaw ) -> MemOptimizedTrieNode<CacheAlgoDataT>
sourcepub unsafe fn copy_and_replace_fields(
&self,
new_value: Option<Option<Box<[u8]>>>,
new_path: Option<CompressedPathRaw>,
children_table: Option<ChildrenTableDeltaMpt>
) -> MemOptimizedTrieNode<CacheAlgoDataT>
pub unsafe fn copy_and_replace_fields( &self, new_value: Option<Option<Box<[u8]>>>, new_path: Option<CompressedPathRaw>, children_table: Option<ChildrenTableDeltaMpt> ) -> MemOptimizedTrieNode<CacheAlgoDataT>
new_value can only be set according to the situation. children_table can only be replaced when there is no children in both old and new table.
unsafe because:
- precondition on children_table;
- delete value assumes that self contains some value.
sourcepub fn check_delete_value(&self) -> Result<TrieNodeAction>
pub fn check_delete_value(&self) -> Result<TrieNodeAction>
Returns: old_value, is_self_about_to_delete, replacement_node_for_self
pub unsafe fn set_first_child_unchecked( &mut self, child_index: u8, child: NodeRefDeltaMptCompact )
sourcepub fn check_replace_or_delete_child_action(
&self,
child_index: u8,
new_child_node: Option<NodeRefDeltaMptCompact>
) -> TrieNodeAction
pub fn check_replace_or_delete_child_action( &self, child_index: u8, new_child_node: Option<NodeRefDeltaMptCompact> ) -> TrieNodeAction
Returns old_child, is_self_about_to_delete, replacement_node_for_self
pub fn get_merkle(&self) -> &MerkleHash
pub fn set_merkle(&mut self, merkle: &MerkleHash)
Trait Implementations§
source§impl<CacheAlgoDataT: CacheAlgoDataTrait> Clone for MemOptimizedTrieNode<CacheAlgoDataT>
impl<CacheAlgoDataT: CacheAlgoDataTrait> Clone for MemOptimizedTrieNode<CacheAlgoDataT>
source§impl<CacheAlgoDataT: CacheAlgoDataTrait> Debug for MemOptimizedTrieNode<CacheAlgoDataT>
impl<CacheAlgoDataT: CacheAlgoDataTrait> Debug for MemOptimizedTrieNode<CacheAlgoDataT>
source§impl<CacheAlgoDataT: CacheAlgoDataTrait> Decodable for MemOptimizedTrieNode<CacheAlgoDataT>
impl<CacheAlgoDataT: CacheAlgoDataTrait> Decodable for MemOptimizedTrieNode<CacheAlgoDataT>
source§impl<CacheAlgoDataT: Default + CacheAlgoDataTrait> Default for MemOptimizedTrieNode<CacheAlgoDataT>
impl<CacheAlgoDataT: Default + CacheAlgoDataTrait> Default for MemOptimizedTrieNode<CacheAlgoDataT>
source§fn default() -> MemOptimizedTrieNode<CacheAlgoDataT>
fn default() -> MemOptimizedTrieNode<CacheAlgoDataT>
source§impl<CacheAlgoDataT: CacheAlgoDataTrait> Encodable for MemOptimizedTrieNode<CacheAlgoDataT>
impl<CacheAlgoDataT: CacheAlgoDataTrait> Encodable for MemOptimizedTrieNode<CacheAlgoDataT>
source§impl<CacheAlgoDataT: CacheAlgoDataTrait> MallocSizeOf for MemOptimizedTrieNode<CacheAlgoDataT>
impl<CacheAlgoDataT: CacheAlgoDataTrait> MallocSizeOf for MemOptimizedTrieNode<CacheAlgoDataT>
source§fn size_of(&self, ops: &mut MallocSizeOfOps) -> usize
fn size_of(&self, ops: &mut MallocSizeOfOps) -> usize
source§impl<CacheAlgoDataT: CacheAlgoDataTrait> PartialEq for MemOptimizedTrieNode<CacheAlgoDataT>
impl<CacheAlgoDataT: CacheAlgoDataTrait> PartialEq for MemOptimizedTrieNode<CacheAlgoDataT>
impl<CacheAlgoDataT: CacheAlgoDataTrait> Send for MemOptimizedTrieNode<CacheAlgoDataT>
Compiler is not sure about the pointer in MaybeInPlaceByteArray fields. It’s Send because TrieNode is move only and it’s impossible to change any part of it without &mut.
impl<CacheAlgoDataT: CacheAlgoDataTrait> Sync for MemOptimizedTrieNode<CacheAlgoDataT>
Compiler is not sure about the pointer in MaybeInPlaceByteArray fields. We do not allow a &TrieNode to be able to change anything the pointer is pointing to, therefore TrieNode is Sync.