Options
All
  • Public
  • Public/Protected
  • All
Menu

Class ENR

Hierarchy

Index

Constructors

constructor

  • new ENR(kvs?: Record<string, Uint8Array>, seq?: bigint, signature?: null | Buffer): ENR
  • Parameters

    • kvs: Record<string, Uint8Array> = {}
    • seq: bigint = ...
    • signature: null | Buffer = null

    Returns ENR

Properties

Readonly [toStringTag]

[toStringTag]: string

seq

seq: bigint

signature

signature: null | Buffer

Readonly size

size: number

Static Readonly RECORD_PREFIX

RECORD_PREFIX: "enr:" = 'enr:'

Static Readonly [species]

[species]: MapConstructor

Accessors

id

  • get id(): string

ip

  • get ip(): undefined | string
  • set ip(ip: undefined | string): void

ip6

  • get ip6(): undefined | string
  • set ip6(ip: undefined | string): void

keypair

keypairType

multiaddrs

  • get multiaddrs(): undefined | Multiaddr[]
  • set multiaddrs(multiaddrs: undefined | Multiaddr[]): void
  • Get the multiaddrs field from ENR.

    This field is used to store multiaddresses that cannot be stored with the current ENR pre-defined keys. These can be a multiaddresses that include encapsulation (e.g. wss) or do not use ip4 nor ip6 for the host address (e.g. dns4, dnsaddr, etc)..

    If the peer information only contains information that can be represented with the ENR pre-defined keys (ip, tcp, etc) then the usage of getLocationMultiaddr should be preferred.

    The multiaddresses stored in this field are expected to be location multiaddresses, ie, peer id less.

    Returns undefined | Multiaddr[]

  • Set the multiaddrs field on the ENR.

    This field is used to store multiaddresses that cannot be stored with the current ENR pre-defined keys. These can be a multiaddresses that include encapsulation (e.g. wss) or do not use ip4 nor ip6 for the host address (e.g. dns4, dnsaddr, etc)..

    If the peer information only contains information that can be represented with the ENR pre-defined keys (ip, tcp, etc) then the usage of setLocationMultiaddr should be preferred.

    The multiaddresses stored in this field must to be location multiaddresses, ie, peer id less.

    Parameters

    • multiaddrs: undefined | Multiaddr[]

    Returns void

nodeId

  • get nodeId(): string

peerId

  • get peerId(): PeerId

publicKey

  • get publicKey(): Buffer

tcp

  • get tcp(): undefined | number
  • set tcp(port: undefined | number): void

tcp6

  • get tcp6(): undefined | number
  • set tcp6(port: undefined | number): void

udp

  • get udp(): undefined | number
  • set udp(port: undefined | number): void

udp6

  • get udp6(): undefined | number
  • set udp6(port: undefined | number): void

Methods

[iterator]

  • [iterator](): IterableIterator<[string, Uint8Array]>
  • Returns an iterable of entries in the map.

    Returns IterableIterator<[string, Uint8Array]>

clear

  • clear(): void
  • Returns void

delete

  • delete(key: string): boolean
  • Parameters

    • key: string

    Returns boolean

encode

  • encode(privateKey?: Buffer): Buffer

encodeToValues

  • encodeToValues(privateKey?: Buffer): (string | number | Uint8Array)[]
  • Parameters

    • Optional privateKey: Buffer

    Returns (string | number | Uint8Array)[]

encodeTxt

  • encodeTxt(privateKey?: Buffer): string

entries

  • entries(): IterableIterator<[string, Uint8Array]>
  • Returns an iterable of key, value pairs for every entry in the map.

    Returns IterableIterator<[string, Uint8Array]>

forEach

  • forEach(callbackfn: (value: Uint8Array, key: string, map: Map<string, Uint8Array>) => void, thisArg?: any): void
  • Parameters

    • callbackfn: (value: Uint8Array, key: string, map: Map<string, Uint8Array>) => void
        • (value: Uint8Array, key: string, map: Map<string, Uint8Array>): void
        • Parameters

          • value: Uint8Array
          • key: string
          • map: Map<string, Uint8Array>

          Returns void

    • Optional thisArg: any

    Returns void

get

  • get(key: string): undefined | Uint8Array
  • Parameters

    • key: string

    Returns undefined | Uint8Array

getFullMultiaddr

  • getFullMultiaddr(protocol: "udp" | "udp4" | "udp6" | "tcp" | "tcp4" | "tcp6"): undefined | Multiaddr
  • Returns the full multiaddr from the ENR fields matching the provided protocol parameter. To return full multiaddrs from the multiaddrs ENR field, use ENR.getFullMultiaddrs

    Parameters

    • protocol: "udp" | "udp4" | "udp6" | "tcp" | "tcp4" | "tcp6"

    Returns undefined | Multiaddr

getFullMultiaddrs

  • getFullMultiaddrs(): Multiaddr[]
  • Returns the full multiaddrs from the multiaddrs ENR field.

    Returns Multiaddr[]

getLocationMultiaddr

  • getLocationMultiaddr(protocol: "udp" | "udp4" | "udp6" | "tcp" | "tcp4" | "tcp6"): undefined | Multiaddr
  • Parameters

    • protocol: "udp" | "udp4" | "udp6" | "tcp" | "tcp4" | "tcp6"

    Returns undefined | Multiaddr

has

  • has(key: string): boolean
  • Parameters

    • key: string

    Returns boolean

keys

  • keys(): IterableIterator<string>
  • Returns an iterable of keys in the map

    Returns IterableIterator<string>

set

  • set(k: string, v: Uint8Array): ENR

setLocationMultiaddr

  • setLocationMultiaddr(multiaddr: Multiaddr): void

sign

  • sign(data: Buffer, privateKey: Buffer): Buffer

values

  • values(): IterableIterator<Uint8Array>
  • Returns an iterable of values in the map

    Returns IterableIterator<Uint8Array>

verify

  • verify(data: Buffer, signature: Buffer): boolean

Static createFromPeerId

  • createFromPeerId(peerId: PeerId, kvs?: Record<string, Uint8Array>): ENR

Static createV4

  • createV4(publicKey: Buffer, kvs?: Record<string, Uint8Array>): ENR

Static decode

  • decode(encoded: Buffer): ENR

Static decodeFromValues

  • decodeFromValues(decoded: Buffer[]): ENR

Static decodeTxt

  • decodeTxt(encoded: string): ENR

Generated using TypeDoc