Options
All
  • Public
  • Public/Protected
  • All
Menu

Class BranchNode<V>

Represents a branch node in the tree. A branch node contains 16 branches, one for each hex character, and may also act as a "leaf" node by containing a value.

Type parameters

  • V

Hierarchy

Index

Properties

branches

branches: Array<MerklePatriciaTreeNode<V>> = new Array<MerklePatriciaTreeNode<V>>(16)

An array of branches this tree node holds.

markForCopy

markForCopy: boolean = false

Only used for batchCOW to mark nodes to be copied

nibbles

nibbles: number[] = []

A branch node has no nibbles to be set.

rlpNodeEncoding

rlpNodeEncoding: Buffer | null = null

Memoizing RLP encoding of the serialized node

value

value: V | null = null

The value this branch holds, initially unset.

Static HUMAN_READABLE_HASH_LENGTH

HUMAN_READABLE_HASH_LENGTH: number = 6

When calling toString(), sets the length of the hashes printed.

Static HUMAN_READABLE_VAL_LENGTH

HUMAN_READABLE_VAL_LENGTH: number = 6

When calling toString(), sets the length of the values printed. Values longer will be appended with ...

Methods

clearMemoizedHash

  • clearMemoizedHash(): void

clearRlpNodeEncoding

  • clearRlpNodeEncoding(): void

getNodeRlpSize

getRlpNodeEncoding

hash

  • Return the hash for the node.

    Parameters

    • options: MerklePatriciaTreeOptions<__type, V>
    • Default value rlpEncodedBuffer: Buffer | null = null

      An optional RLP encoded buffer of the node to use for hashing

    Returns bigint

    A Buffer containing the hash for the node.

next

  • next(nibbles: number[]): object | object

serialize

toReadableHash

toString

  • Returns the string representation of this node.

    Parameters

    Returns string

    The string representation of this node.

Static bufferToNibbles

  • bufferToNibbles(buffer: Buffer): number[]

Static fromBuffer

  • fromBuffer(out: Buffer): object

Static intersectingPrefix

  • intersectingPrefix(n0: number[], n1: number[]): number[]
  • Return the intersecting prefix, which contains the nibbles shared by both n0 and n1 at the beginning of each nibble set.

    Parameters

    • n0: number[]

      The first set of nibbles

    • n1: number[]

      The second set of nibbles

    Returns number[]

    A set of nibbles representing the intersecting prefix of both input sets.

Static nibblesAsHex

  • nibblesAsHex(nibbles: number[]): string
  • Converts a set of nibbles to its representation as a hex string.

    Parameters

    • nibbles: number[]

      The nibbles to convert.

    Returns string

    The input nibbles as a hex string.

Static toBuffer

  • toBuffer(nibbles: number[], prefix: number): Buffer
  • Converts a set of nibbles and an attached prefix to its buffer representation.

    Parameters

    • nibbles: number[]

      The nibbles to convert.

    • prefix: number

      The prefix for the nibbles to convert.

    Returns Buffer

    The representation of the nibbles with the given prefix as a buffer.

Static toReadableValue

  • toReadableValue<V>(val: V): string
  • Converts a value to a human readable value. This is set to the first n characters of the hex representation of a value, as defined by HUMAN_READABLE_VAL_LENGTH.

    Type parameters

    • V

    Parameters

    • val: V

      The value to convert.

    Returns string

    A human readable value string

Generated using TypeDoc