pub struct TrieWalker<C, K = AddedRemovedKeys> {
pub cursor: C,
pub stack: Vec<CursorSubNode>,
pub can_skip_current_node: bool,
pub changes: PrefixSet,
/* private fields */
}Expand description
Traverses the trie in lexicographic order.
This iterator depends on the ordering guarantees of TrieCursor.
Fields§
§cursor: CA mutable reference to a trie cursor instance used for navigating the trie.
stack: Vec<CursorSubNode>A vector containing the trie nodes that have been visited.
can_skip_current_node: boolA flag indicating whether the current node can be skipped when traversing the trie. This is determined by whether the current key’s prefix is included in the prefix set and if the hash flag is set.
changes: PrefixSetA PrefixSet representing the changes to be applied to the trie.
Implementations§
Source§impl<C: TrieCursor, K: AsRef<AddedRemovedKeys>> TrieWalker<C, K>
impl<C: TrieCursor, K: AsRef<AddedRemovedKeys>> TrieWalker<C, K>
Sourcepub fn state_trie_from_stack(
cursor: C,
stack: Vec<CursorSubNode>,
changes: PrefixSet,
) -> Self
pub fn state_trie_from_stack( cursor: C, stack: Vec<CursorSubNode>, changes: PrefixSet, ) -> Self
Constructs a new TrieWalker for the state trie from existing stack and a cursor.
Sourcepub fn storage_trie_from_stack(
cursor: C,
stack: Vec<CursorSubNode>,
changes: PrefixSet,
) -> Self
pub fn storage_trie_from_stack( cursor: C, stack: Vec<CursorSubNode>, changes: PrefixSet, ) -> Self
Constructs a new TrieWalker for the storage trie from existing stack and a cursor.
Sourcepub fn with_deletions_retained(self, retained: bool) -> Self
pub fn with_deletions_retained(self, retained: bool) -> Self
Sets the flag whether the trie updates should be stored.
Sourcepub fn with_added_removed_keys<K2>(
self,
added_removed_keys: Option<K2>,
) -> TrieWalker<C, K2>
pub fn with_added_removed_keys<K2>( self, added_removed_keys: Option<K2>, ) -> TrieWalker<C, K2>
Configures the walker to not skip certain branch nodes, even when they are not in the
PrefixSet, when they might be needed to support leaf removal.
Sourcepub const fn with_walk_all_changed_branch_children(self, enabled: bool) -> Self
pub const fn with_walk_all_changed_branch_children(self, enabled: bool) -> Self
Configures the walker to treat every child of a matching branch path as unskippable.
When deletions are retained, also collects stored descendants hidden by a matching branch’s tree mask. These keys appear in the deletion set even if traversal never visits them. Root calculations can replace these deletions with regenerated branch updates.
Sourcepub fn split(self) -> (Vec<CursorSubNode>, HashSet<Nibbles>)
pub fn split(self) -> (Vec<CursorSubNode>, HashSet<Nibbles>)
Split the walker into stack and trie updates.
Sourcepub fn take_removed_keys(&mut self) -> HashSet<Nibbles>
pub fn take_removed_keys(&mut self) -> HashSet<Nibbles>
Take removed keys from the walker.
Sourcepub fn print_stack(&self)
pub fn print_stack(&self)
Prints the current stack of trie nodes.
Sourcepub fn removed_keys_len(&self) -> usize
pub fn removed_keys_len(&self) -> usize
The current length of the removed keys.
Sourcepub fn maybe_hash(&self) -> Option<B256>
pub fn maybe_hash(&self) -> Option<B256>
Returns the current hash in the trie, if any.
Differs from Self::hash in that it returns None if the subnode is positioned at the
child without a hash mask bit set. Self::hash panics in that case.
Sourcepub fn children_are_in_trie(&self) -> bool
pub fn children_are_in_trie(&self) -> bool
Indicates whether the children of the current node are present in the trie.
Sourcepub fn next_unprocessed_key(&self) -> Option<(B256, Nibbles)>
pub fn next_unprocessed_key(&self) -> Option<(B256, Nibbles)>
Returns the next unprocessed key in the trie along with its raw Nibbles representation.
Sourcepub fn state_trie(cursor: C, changes: PrefixSet) -> Result<Self, DatabaseError>
pub fn state_trie(cursor: C, changes: PrefixSet) -> Result<Self, DatabaseError>
Constructs a new TrieWalker for the state trie.
Sourcepub fn storage_trie(
cursor: C,
changes: PrefixSet,
) -> Result<Self, DatabaseError>
pub fn storage_trie( cursor: C, changes: PrefixSet, ) -> Result<Self, DatabaseError>
Constructs a new TrieWalker for the storage trie.
Trait Implementations§
Auto Trait Implementations§
impl<C, K = AddedRemovedKeys> !RefUnwindSafe for TrieWalker<C, K>
impl<C, K = AddedRemovedKeys> !UnwindSafe for TrieWalker<C, K>
impl<C, K> Freeze for TrieWalker<C, K>
impl<C, K> Send for TrieWalker<C, K>
impl<C, K> Sync for TrieWalker<C, K>
impl<C, K> Unpin for TrieWalker<C, K>
impl<C, K> UnsafeUnpin for TrieWalker<C, K>
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
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
Source§fn in_current_span(self) -> Instrumented<Self> ⓘ
fn in_current_span(self) -> Instrumented<Self> ⓘ
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreimpl<T> MaybeDebug for Twhere
T: Debug,
§impl<T> Pointable for T
impl<T> Pointable for T
impl<T> Read<Exclusive, BecauseExclusive> for Twhere
T: ?Sized,
§impl<T> WithSubscriber for T
impl<T> WithSubscriber for T
§fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self> ⓘwhere
S: Into<Dispatch>,
fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self> ⓘwhere
S: Into<Dispatch>,
§fn with_current_subscriber(self) -> WithDispatch<Self> ⓘ
fn with_current_subscriber(self) -> WithDispatch<Self> ⓘ
Source§impl<T> WithSubscriber for T
impl<T> WithSubscriber for T
Source§fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self> ⓘwhere
S: Into<Dispatch>,
fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self> ⓘwhere
S: Into<Dispatch>,
Source§fn with_current_subscriber(self) -> WithDispatch<Self> ⓘ
fn with_current_subscriber(self) -> WithDispatch<Self> ⓘ
Layout§
Note: Unable to compute type layout, possibly due to this type having generic parameters. Layout can only be computed for concrete, fully-instantiated types.