Skip to content

Latest commit

 

History

History
292 lines (172 loc) · 7.59 KB

README.md

File metadata and controls

292 lines (172 loc) · 7.59 KB

@ethereumjs/trie

@ethereumjs/trie

Table of contents

Classes

Interfaces

Type Aliases

Variables

Functions

Type Aliases

BatchDBOp

Ƭ BatchDBOp: PutBatch | DelBatch

Defined in

packages/trie/src/types.ts:72


Checkpoint

Ƭ Checkpoint: Object

Type declaration

Name Type
keyValueMap Map<string, Buffer | null>
root Buffer

Defined in

packages/trie/src/types.ts:119


EmbeddedNode

Ƭ EmbeddedNode: Buffer | Buffer[]

Defined in

packages/trie/src/types.ts:10


FoundNodeFunction

Ƭ FoundNodeFunction: (nodeRef: Buffer, node: TrieNode | null, key: Nibbles, walkController: WalkController) => void

Type declaration

▸ (nodeRef, node, key, walkController): void

Parameters
Name Type
nodeRef Buffer
node TrieNode | null
key Nibbles
walkController WalkController
Returns

void

Defined in

packages/trie/src/types.ts:14


HashKeysFunction

Ƭ HashKeysFunction: (msg: Uint8Array) => Uint8Array

Type declaration

▸ (msg): Uint8Array

Parameters
Name Type
msg Uint8Array
Returns

Uint8Array

Defined in

packages/trie/src/types.ts:21


Nibbles

Ƭ Nibbles: number[]

Defined in

packages/trie/src/types.ts:6


Proof

Ƭ Proof: Buffer[]

Defined in

packages/trie/src/types.ts:12


TrieNode

Ƭ TrieNode: BranchNode | ExtensionNode | LeafNode

Defined in

packages/trie/src/types.ts:4


TrieOptsWithDefaults

Ƭ TrieOptsWithDefaults: TrieOpts & { useKeyHashing: boolean ; useKeyHashingFunction: HashKeysFunction ; useNodePruning: boolean ; useRootPersistence: boolean }

Defined in

packages/trie/src/types.ts:65

Variables

ROOT_DB_KEY

Const ROOT_DB_KEY: Buffer

Defined in

packages/trie/src/types.ts:126

Functions

decodeNode

decodeNode(raw): BranchNode | ExtensionNode | LeafNode

Parameters

Name Type
raw Buffer

Returns

BranchNode | ExtensionNode | LeafNode

Defined in

packages/trie/src/trie/node/util.ts:25


decodeRawNode

decodeRawNode(raw): BranchNode | ExtensionNode | LeafNode

Parameters

Name Type
raw Buffer[]

Returns

BranchNode | ExtensionNode | LeafNode

Defined in

packages/trie/src/trie/node/util.ts:11


isRawNode

isRawNode(n): boolean

Parameters

Name Type
n any

Returns

boolean

Defined in

packages/trie/src/trie/node/util.ts:33


verifyRangeProof

verifyRangeProof(rootHash, firstKey, lastKey, keys, values, proof, useKeyHashingFunction): Promise<boolean>

verifyRangeProof checks whether the given leaf nodes and edge proof can prove the given trie leaves range is matched with the specific root.

There are four situations:

  • All elements proof. In this case the proof can be null, but the range should be all the leaves in the trie.

  • One element proof. In this case no matter the edge proof is a non-existent proof or not, we can always verify the correctness of the proof.

  • Zero element proof. In this case a single non-existent proof is enough to prove. Besides, if there are still some other leaves available on the right side, then an error will be returned.

  • Two edge elements proof. In this case two existent or non-existent proof(first and last) should be provided.

NOTE: Currently only supports verification when the length of firstKey and lastKey are the same.

Parameters

Name Type Description
rootHash Buffer root hash.
firstKey null | Nibbles first key.
lastKey null | Nibbles last key.
keys Nibbles[] key list.
values Buffer[] value list, one-to-one correspondence with keys.
proof null | Buffer[] proof node list, if proof is null, both firstKey and lastKey must be null
useKeyHashingFunction HashKeysFunction -

Returns

Promise<boolean>

a flag to indicate whether there exists more trie node in the trie

Defined in

packages/trie/src/proof/range.ts:410