merkle-patricia-tree › "util/walkController" › WalkController
WalkController is an interface to control how the trie is being traversed.
- WalkController
• onNode: FoundNodeFunction
Defined in util/walkController.ts:10
• taskExecutor: PrioritizedTaskExecutor
Defined in util/walkController.ts:11
• trie: BaseTrie
Defined in util/walkController.ts:12
▸ allChildren(node
: TrieNode, key
: Nibbles): void
Defined in util/walkController.ts:59
Run all children of a node. Priority of these nodes are the key length of the children.
Parameters:
Name | Type | Default | Description |
---|---|---|---|
node |
TrieNode | - | Node to get all children of and call onNode on. |
key |
Nibbles | [] | The current key which would yield the node when trying to get this node with a get operation. |
Returns: void
▸ onlyBranchIndex(node
: BranchNode, key
: Nibbles, childIndex
: number, priority?
: undefined | number): void
Defined in util/walkController.ts:105
Push a branch of a certain BranchNode to the event queue.
Parameters:
Name | Type | Default | Description |
---|---|---|---|
node |
BranchNode | - | The node to select a branch on. Should be a BranchNode. |
key |
Nibbles | [] | The current key which leads to the corresponding node. |
childIndex |
number | - | The child index to add to the event queue. |
priority? |
undefined | number | - | Optional priority of the event, defaults to the total key length. |
Returns: void
▸ pushNodeToQueue(nodeRef
: Buffer, key
: Nibbles, priority?
: undefined | number): void
Defined in util/walkController.ts:87
Push a node to the queue. If the queue has places left for tasks, the node is executed immediately, otherwise it is queued.
Parameters:
Name | Type | Default | Description |
---|---|---|---|
nodeRef |
Buffer | - | Push a node reference to the event queue. This reference is a 32-byte keccak hash of the value corresponding to the key . |
key |
Nibbles | [] | The current key. |
priority? |
undefined | number | - | Optional priority, defaults to key length |
Returns: void
▸ newWalk(onNode
: FoundNodeFunction, trie
: BaseTrie, root
: Buffer, poolSize?
: undefined | number): Promise‹void›
Defined in util/walkController.ts:35
Async function to create and start a new walk over a trie.
Parameters:
Name | Type | Description |
---|---|---|
onNode |
FoundNodeFunction | The `FoundNodeFunction to call if a node is found. |
trie |
BaseTrie | The trie to walk on. |
root |
Buffer | The root key to walk on. |
poolSize? |
undefined | number | Task execution pool size to prevent OOM errors. Defaults to 500. |
Returns: Promise‹void›