Options
All
  • Public
  • Public/Protected
  • All
Menu

Class ExtensionNode<V>

Represents an extension node, which "consumes" a set of nibbles and points to another node.

Type parameters

  • V

Hierarchy

Index

Constructors

constructor

  • Construct a new extension node.

    Parameters

    • nibbles: number[]

      The nibbles that will be consumed when this node is traversed.

    • nextNode: MerklePatriciaTreeNode<V>

      The node that this node points to.

    Returns ExtensionNode

Properties

markForCopy

markForCopy: boolean = false

Only used for batchCOW to mark nodes to be copied

nextNode

The node that this node points to.

nibbles

nibbles: number[]

The nibbles that will be consumed when this node is traversed.

rlpNodeEncoding

rlpNodeEncoding: Buffer | null = null

Memoizing RLP encoding of the serialized node

value

value: null = null

Extension nodes never contain a value.

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 ...

Static PREFIX_EXTENSION_EVEN

PREFIX_EXTENSION_EVEN: number = 0

The prefix when the number of nibbles in the extension node is even.

Static PREFIX_EXTENSION_ODD

PREFIX_EXTENSION_ODD: number = 1

The prefix when the number of nibbles in the extension node is odd.

Accessors

prefix

  • get prefix(): number
  • Return the prefix for this extension node.

    Returns number

    The prefix for the node.

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