@ethereumjs/mpt / WalkController
Defined in: packages/mpt/src/util/walkController.ts:14
Interface to control how the trie is being traversed. Schedules node visits via a prioritized task queue and invokes the provided callback for each node.
Used by MerklePatriciaTrie.findPath, MerklePatriciaTrie.walkTrie, etc.
readonlyonNode:FoundNodeFunction
Defined in: packages/mpt/src/util/walkController.ts:16
The FoundNodeFunction to call when a node is found.
readonlytaskExecutor:PrioritizedTaskExecutor
Defined in: packages/mpt/src/util/walkController.ts:19
Task executor that prioritizes node visits (shorter paths first).
readonlytrie:MerklePatriciaTrie
Defined in: packages/mpt/src/util/walkController.ts:22
The trie being walked.
allChildren(
node,currentKeyNibbles):void
Defined in: packages/mpt/src/util/walkController.ts:84
Runs all children of a node. Priority of these nodes is the key length of the children. Used when walking an Extension or when exploring all branches of a Branch node.
Node to get all children of and call onNode on.
Nibbles = []
The current key (nibbles) which would yield the node when
trying to get this node with a get operation. Defaults to [].
void
void
onlyBranchIndex(
node,currentKeyNibbles,childIndex,priority?):void
Defined in: packages/mpt/src/util/walkController.ts:144
Pushes a branch of a certain BranchMPTNode to the event queue. Used by findPath when following a specific key (only one child index is traversed).
The BranchMPTNode to select a branch on.
Nibbles = []
The current key which leads to the corresponding node. Defaults to [].
number
The child index (0–15) to add to the event queue.
number
Optional priority of the event. Defaults to the total key length.
void
void
If node is not a BranchMPTNode or if the branch at childIndex is empty.
pushNodeToQueue(
nodeRef,currentKeyNibbles,priority?):void
Defined in: packages/mpt/src/util/walkController.ts:114
Pushes a node to the queue. If the queue has capacity, the node is executed immediately, otherwise it is queued for later execution.
A node reference (32-byte keccak hash or raw encoding) to enqueue.
Nibbles = []
The current key (nibbles) corresponding to this node. Defaults to [].
number
Optional priority. Defaults to key length.
void
void
staticnewWalk(onNode,trie,rootHash,poolSize?):Promise<void>
Defined in: packages/mpt/src/util/walkController.ts:50
Creates and starts an async walk over a trie from the given root. Resolves when all reachable nodes have been visited and no new tasks were scheduled.
The FoundNodeFunction to call when a node is found.
The trie to walk on.
Uint8Array
The root hash (32-byte keccak) to start walking from.
number
Task execution pool size to prevent OOM errors. Defaults to 500.
Promise<void>
A Promise that resolves when the walk is finished.