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

primitives/PeerInfo

Type Aliases

PeerInfoType

PeerInfoType = object
Defined in: src/primitives/PeerInfo/PeerInfoType.ts:16 Peer information structure from admin_peers RPC method Contains metadata about a connected peer including:
  • Peer identity (ID, name, capabilities)
  • Network connection details (local/remote addresses, direction)
  • Protocol-specific state (difficulty, head block)

See

https://geth.ethereum.org/docs/interacting-with-geth/rpc/ns-admin#admin-peers

Properties

caps
readonly caps: readonly string[]
Defined in: src/primitives/PeerInfo/PeerInfoType.ts:22 Supported capabilities (e.g., [“eth/67”, “snap/1”])
id
readonly id: PeerIdType
Defined in: src/primitives/PeerInfo/PeerInfoType.ts:18 Peer ID (enode URL)
name
readonly name: string
Defined in: src/primitives/PeerInfo/PeerInfoType.ts:20 Remote client identifier (e.g., “Geth/v1.10.26-stable”)
network
readonly network: object
Defined in: src/primitives/PeerInfo/PeerInfoType.ts:24 Network connection information
inbound
readonly inbound: boolean
True if inbound connection
localAddress
readonly localAddress: string
Local endpoint (IP:PORT)
remoteAddress
readonly remoteAddress: string
Remote endpoint (IP:PORT)
static
readonly static: boolean
True if static node
trusted
readonly trusted: boolean
True if trusted peer
protocols
readonly protocols: object
Defined in: src/primitives/PeerInfo/PeerInfoType.ts:37 Protocol-specific information
Index Signature
[protocol: string]: unknown Other protocols
eth?
readonly optional eth: object
Ethereum protocol info (if supported)
eth.difficulty
readonly difficulty: BrandedUint
Total difficulty of peer’s chain
eth.head
readonly head: BlockHashType
Peer’s head block hash
eth.version
readonly version: ProtocolVersionType
Protocol version

Variables

PeerInfo

const PeerInfo: object
Defined in: src/primitives/PeerInfo/index.ts:29

Type Declaration

from()
from: (value) => PeerInfoType
Create PeerInfo from RPC response object
Parameters
value
any Peer info object from admin_peers
Returns
PeerInfoType Peer information
Throws
If value is not a valid peer info object
Example
import * as PeerInfo from './primitives/PeerInfo/index.js';
const peers = rpcResponse.map(peer => PeerInfo.from(peer));
peers.forEach(peer => {
  console.log(peer.name);
  console.log(peer.network.inbound);
});
hasCapability()
hasCapability: (peerInfo, capability) => boolean
Parameters
peerInfo
any
capability
string
Returns
boolean
isInbound()
isInbound: (peerInfo) => boolean
Parameters
peerInfo
any
Returns
boolean

Functions

_hasCapability()

_hasCapability(this, capability): boolean
Defined in: src/primitives/PeerInfo/hasCapability.js:15 Check if peer supports a specific capability

Parameters

this
PeerInfoType
capability
string Capability to check (e.g., “eth/67”, “snap/1”)

Returns

boolean True if peer supports capability

Example

import * as PeerInfo from './primitives/PeerInfo/index.js';
const peer = PeerInfo.from(rpcResponse);
const hasEth67 = PeerInfo._hasCapability.call(peer, "eth/67");

_isInbound()

_isInbound(this): boolean
Defined in: src/primitives/PeerInfo/isInbound.js:14 Check if peer connection is inbound

Parameters

this
PeerInfoType

Returns

boolean True if inbound connection

Example

import * as PeerInfo from './primitives/PeerInfo/index.js';
const peer = PeerInfo.from(rpcResponse);
const inbound = PeerInfo._isInbound.call(peer);

from()

from(value): PeerInfoType
Defined in: src/primitives/PeerInfo/from.js:25 Create PeerInfo from RPC response object

Parameters

value
any Peer info object from admin_peers

Returns

PeerInfoType Peer information

Throws

If value is not a valid peer info object

Example

import * as PeerInfo from './primitives/PeerInfo/index.js';
const peers = rpcResponse.map(peer => PeerInfo.from(peer));
peers.forEach(peer => {
  console.log(peer.name);
  console.log(peer.network.inbound);
});

hasCapability()

hasCapability(peerInfo, capability): boolean
Defined in: src/primitives/PeerInfo/index.ts:14

Parameters

peerInfo
any
capability
string

Returns

boolean

isInbound()

isInbound(peerInfo): boolean
Defined in: src/primitives/PeerInfo/index.ts:20

Parameters

peerInfo
any

Returns

boolean