Skip to main content
@tevm/voltaire
@tevm/voltaire / primitives/PeerId

primitives/PeerId

Type Aliases

EnodeComponents

EnodeComponents = object
Defined in: src/primitives/PeerId/PeerIdType.ts:23 Parsed enode URL components

Properties

discoveryPort?
readonly optional discoveryPort: number
Defined in: src/primitives/PeerId/PeerIdType.ts:31 UDP port for discovery (optional)
ip
readonly ip: string
Defined in: src/primitives/PeerId/PeerIdType.ts:27 IP address (IPv4 or IPv6)
port
readonly port: number
Defined in: src/primitives/PeerId/PeerIdType.ts:29 TCP port for RLPx
publicKey
readonly publicKey: string
Defined in: src/primitives/PeerId/PeerIdType.ts:25 Node public key (128 hex chars)

PeerIdType

PeerIdType = string & object
Defined in: src/primitives/PeerId/PeerIdType.ts:18 Branded PeerId type - Ethereum peer identifier Wraps a string representing a peer ID (typically an enode URL) Enode URL format: enode://PUBKEY@IP:PORT?discport=DISCPORT
  • PUBKEY: 128 hex character node ID (secp256k1 public key)
  • IP: IPv4 or IPv6 address
  • PORT: TCP port for RLPx connection
  • DISCPORT: (optional) UDP port for peer discovery

Type Declaration

[brand]
readonly [brand]: "PeerId"

Example

Variables

PeerId

const PeerId: object
Defined in: src/primitives/PeerId/index.ts:31

Type Declaration

equals()
equals: (peerId1, peerId2) => boolean
Parameters
peerId1
string
peerId2
string
Returns
boolean
from()
from: (value) => PeerIdType
Create PeerId from string
Parameters
value
string Peer ID string (enode URL or node ID)
Returns
PeerIdType Branded peer ID
Throws
If value is not a valid peer ID
Example
parse()
parse: (peerId) => EnodeComponents
Parameters
peerId
string
Returns
EnodeComponents
toString()
toString: (peerId) => string
Parameters
peerId
string
Returns
string

Functions

_equals()

_equals(this, other): boolean
Defined in: src/primitives/PeerId/equals.js:16 Compare two PeerIds for equality

Parameters

this
PeerIdType
other
PeerIdType Peer ID to compare

Returns

boolean True if equal

Example


_parse()

_parse(this): EnodeComponents
Defined in: src/primitives/PeerId/parse.js:21 Parse enode URL into components

Parameters

this
PeerIdType

Returns

EnodeComponents Parsed enode components

Throws

If not a valid enode URL

Example


_toString()

_toString(this): string
Defined in: src/primitives/PeerId/toString.js:15 Convert PeerId to string (identity function for branded type)

Parameters

this
PeerIdType

Returns

string Peer ID as string

Example


equals()

equals(peerId1, peerId2): boolean
Defined in: src/primitives/PeerId/index.ts:19

Parameters

peerId1
string
peerId2
string

Returns

boolean

from()

from(value): PeerIdType
Defined in: src/primitives/PeerId/from.js:16 Create PeerId from string

Parameters

value
string Peer ID string (enode URL or node ID)

Returns

PeerIdType Branded peer ID

Throws

If value is not a valid peer ID

Example


parse()

parse(peerId): EnodeComponents
Defined in: src/primitives/PeerId/index.ts:23

Parameters

peerId
string

Returns

EnodeComponents

toString()

toString(peerId): string
Defined in: src/primitives/PeerId/index.ts:15

Parameters

peerId
string

Returns

string