Skip to content
This repository was archived by the owner on Jan 19, 2021. It is now read-only.

Latest commit

 

History

History
129 lines (76 loc) · 4.41 KB

_util_walkcontroller_.walkcontroller.md

File metadata and controls

129 lines (76 loc) · 4.41 KB

merkle-patricia-tree"util/walkController"WalkController

Class: WalkController

WalkController is an interface to control how the trie is being traversed.

Hierarchy

  • WalkController

Index

Properties

Methods

Properties

onNode

onNode: FoundNodeFunction

Defined in util/walkController.ts:10


taskExecutor

taskExecutor: PrioritizedTaskExecutor

Defined in util/walkController.ts:11


trie

trie: BaseTrie

Defined in util/walkController.ts:12

Methods

allChildren

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

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

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


Static newWalk

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›