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>

source

pub fn get_compressed_path_size(&self) -> u16

source

pub fn copy_compressed_path<CompressedPath: CompressedPathTrait>( &mut self, new_path: CompressedPath )

source

pub fn value_clone(&self) -> MptValue<Box<[u8]>>

source

pub fn check_value_size(value: &[u8]) -> Result<()>

source

pub fn check_key_size(access_key: &[u8]) -> Result<()>

source§

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.

source

pub fn new( merkle: MerkleHash, children_table: ChildrenTableDeltaMpt, maybe_value: Option<Box<[u8]>>, compressed_path: CompressedPathRaw ) -> MemOptimizedTrieNode<CacheAlgoDataT>

source

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:

  1. precondition on children_table;
  2. delete value assumes that self contains some value.
source

pub fn check_delete_value(&self) -> Result<TrieNodeAction>

Returns: old_value, is_self_about_to_delete, replacement_node_for_self

source

pub unsafe fn set_first_child_unchecked( &mut self, child_index: u8, child: NodeRefDeltaMptCompact )

source

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

source

pub fn get_merkle(&self) -> &MerkleHash

source

pub fn set_merkle(&mut self, merkle: &MerkleHash)

Trait Implementations§

source§

impl<CacheAlgoDataT: CacheAlgoDataTrait> Clone for MemOptimizedTrieNode<CacheAlgoDataT>

source§

fn clone(&self) -> Self

Returns a copy of the value. Read more
1.0.0 · source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
source§

impl<CacheAlgoDataT: CacheAlgoDataTrait> Debug for MemOptimizedTrieNode<CacheAlgoDataT>

source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
source§

impl<CacheAlgoDataT: CacheAlgoDataTrait> Decodable for MemOptimizedTrieNode<CacheAlgoDataT>

source§

fn decode(rlp: &Rlp<'_>) -> Result<Self, DecoderError>

Decode a value from RLP bytes
source§

impl<CacheAlgoDataT: Default + CacheAlgoDataTrait> Default for MemOptimizedTrieNode<CacheAlgoDataT>

source§

fn default() -> MemOptimizedTrieNode<CacheAlgoDataT>

Returns the “default value” for a type. Read more
source§

impl<CacheAlgoDataT: CacheAlgoDataTrait> Encodable for MemOptimizedTrieNode<CacheAlgoDataT>

source§

fn rlp_append(&self, s: &mut RlpStream)

Append a value to the stream
§

fn rlp_bytes(&self) -> Vec<u8>

Get rlp-encoded bytes for this instance
source§

impl<CacheAlgoDataT: CacheAlgoDataTrait> MallocSizeOf for MemOptimizedTrieNode<CacheAlgoDataT>

source§

fn size_of(&self, ops: &mut MallocSizeOfOps) -> usize

Measure the heap usage of all descendant heap-allocated structures, but not the space taken up by the value itself.
source§

impl<CacheAlgoDataT: CacheAlgoDataTrait> PartialEq for MemOptimizedTrieNode<CacheAlgoDataT>

source§

fn eq(&self, other: &Self) -> bool

This method tests for self and other values to be equal, and is used by ==.
1.0.0 · source§

fn ne(&self, other: &Rhs) -> bool

This method tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
source§

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.

source§

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.

Auto Trait Implementations§

§

impl<CacheAlgoDataT> RefUnwindSafe for MemOptimizedTrieNode<CacheAlgoDataT>
where CacheAlgoDataT: RefUnwindSafe,

§

impl<CacheAlgoDataT> Unpin for MemOptimizedTrieNode<CacheAlgoDataT>
where CacheAlgoDataT: Unpin,

§

impl<CacheAlgoDataT> UnwindSafe for MemOptimizedTrieNode<CacheAlgoDataT>
where CacheAlgoDataT: UnwindSafe,

Blanket Implementations§

source§

impl<T> Any for T
where T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

impl<T> Borrow<T> for T
where T: ?Sized,

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
source§

impl<T> ElementSatisfy<ElementNoConstrain> for T

source§

impl<T> From<T> for T

source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

impl<T, U> Into<U> for T
where U: From<T>,

source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

source§

impl<T> Same for T

§

type Output = T

Should always be Self
source§

impl<T> ToOwned for T
where T: Clone,

§

type Owned = T

The resulting type after obtaining ownership.
source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

§

type Error = Infallible

The type returned in the event of a conversion error.
source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

§

fn vzip(self) -> V