Options
All
  • Public
  • Public/Protected
  • All
Menu

Class MerklePatriciaTreeNode<V>

Represents an abstract node in a modified Ethereum merkle patricia tree.

Type parameters

  • V

Hierarchy

Index

Properties

markForCopy

markForCopy: boolean = false

Only used for batchCOW to mark nodes to be copied

Abstract nibbles

nibbles: number[]

The nibbles (of the key) used when traversing this node. Not present for branch/null nodes.

rlpNodeEncoding

rlpNodeEncoding: Buffer | null = null

Memoizing RLP encoding of the serialized node

Abstract value

value: V | null

The value stored in the node. Null represents value not present.

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
  • Clears the memoized RLP node encoding

    Returns void

getNodeRlpSize

  • Serializes and computes the RLP encoding of the node and returns the length of the rlp encoding of the node. getNodeRlpSize also stores the computed rlp encoding for future references.

    Parameters

    Returns number

getRlpNodeEncoding

  • Serializes and computes the RLP encoding of the node Also stores it for future references.

    Parameters

    Returns Buffer

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.

Abstract next

  • Get the next node as a result of evaluating the nibbles given.

    Parameters

    • nibbles: number[]

      The nibbles to evaluate

    Returns NextNode<V>

    A [NextNode] with the remaining nibbles and the next node, if any.

Abstract serialize

toReadableHash

  • Converts to node to a human readable hash representation. This is set to the last n characters in the hash, as defined by HUMAN_READABLE_HASH_LENGTH.

    Parameters

    Returns string

    A human readable hash string.

Static bufferToNibbles

  • bufferToNibbles(buffer: Buffer): number[]
  • Convert a buffer into a nibble representation.

    Parameters

    • buffer: Buffer

      The buffer to convert.

    Returns number[]

    An array of nibbles.

Static fromBuffer

  • fromBuffer(out: Buffer): object
  • Converts a buffer to the nibbles and prefix representation.

    Parameters

    • out: Buffer

    Returns object

    nibbles The nibbles to convert.

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