Options
All
  • Public
  • Public/Protected
  • All
Menu

Class ENR

Hierarchy

Index

Constructors

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

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

    Returns ENR

Properties

[toStringTag]: string
peerId?: PeerId
seq: bigint
signature: null | Uint8Array
size: number
RECORD_PREFIX: "enr:" = "enr:"
[species]: MapConstructor

Accessors

  • get id(): string
  • get ip(): undefined | string
  • set ip(ip: undefined | string): void
  • get ip6(): undefined | string
  • set ip6(ip: undefined | string): void
  • 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 be location multiaddresses, ie, without a peer id.

    Parameters

    • multiaddrs: undefined | Multiaddr[]

    Returns void

  • get nodeId(): undefined | string
  • get publicKey(): undefined | Uint8Array
  • get tcp(): undefined | number
  • set tcp(port: undefined | number): void
  • get tcp6(): undefined | number
  • set tcp6(port: undefined | number): void
  • get udp(): undefined | number
  • set udp(port: undefined | number): void
  • get udp6(): undefined | number
  • set udp6(port: undefined | number): void
  • get waku2(): undefined | Waku2
  • set waku2(waku2: undefined | Waku2): void

Methods

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

    Returns IterableIterator<[string, Uint8Array]>

  • clear(): void
  • Returns void

  • delete(key: string): boolean
  • Parameters

    • key: string

    Returns boolean

  • encode(privateKey?: Uint8Array): Promise<Uint8Array>
  • encodeToValues(privateKey?: Uint8Array): Promise<(string | Uint8Array | number[])[]>
  • Parameters

    • Optional privateKey: Uint8Array

    Returns Promise<(string | Uint8Array | number[])[]>

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

    Returns IterableIterator<[string, Uint8Array]>

  • 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(key: string): undefined | Uint8Array
  • Parameters

    • key: string

    Returns undefined | Uint8Array

  • 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(): Multiaddr[]
  • Returns the full multiaddrs from the multiaddrs ENR field.

    Returns Multiaddr[]

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

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

    Returns undefined | Multiaddr

  • has(key: string): boolean
  • Parameters

    • key: string

    Returns boolean

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

    Returns IterableIterator<string>

  • set(k: string, v: Uint8Array): ENR
  • setLocationMultiaddr(multiaddr: Multiaddr): void
  • sign(data: Uint8Array, privateKey: Uint8Array): Promise<Uint8Array>
  • values(): IterableIterator<Uint8Array>
  • Returns an iterable of values in the map

    Returns IterableIterator<Uint8Array>

  • verify(data: Uint8Array, signature: Uint8Array): boolean
  • create(kvs?: Record<string, Uint8Array>, seq?: bigint, signature?: null | Uint8Array): Promise<ENR>
  • Parameters

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

    Returns Promise<ENR>

  • createFromPeerId(peerId: PeerId, kvs?: Record<string, Uint8Array>): Promise<ENR>
  • createV4(publicKey: Uint8Array, kvs?: Record<string, Uint8Array>): Promise<ENR>
  • decode(encoded: Uint8Array): Promise<ENR>
  • decodeFromValues(decoded: Uint8Array[]): Promise<ENR>
  • decodeTxt(encoded: string): Promise<ENR>

Generated using TypeDoc