ethereumjs-monorepo

@ethereumjs/devp2p / Peer

Class: Peer

Table of contents

Constructors

Properties

Methods

Constructors

constructor

new Peer(options)

Parameters

Name Type
options PeerOptions

Defined in

packages/devp2p/src/rlpx/peer.ts:98

Properties

_protocols

_protocols: ProtocolDescriptor[]

Subprotocols (e.g. ETH) derived from the exchange on capabilities

Defined in

packages/devp2p/src/rlpx/peer.ts:96


clientId

Readonly clientId: Uint8Array

Defined in

packages/devp2p/src/rlpx/peer.ts:68


common

common: Common

Defined in

packages/devp2p/src/rlpx/peer.ts:70


events

events: EventEmitter

Defined in

packages/devp2p/src/rlpx/peer.ts:67


id

Readonly id: Uint8Array

Defined in

packages/devp2p/src/rlpx/peer.ts:72

Methods

_addFirstPeerDebugger

_addFirstPeerDebugger(): void

Called once from the subprotocol (e.g. ETH) on the peer where a first successful STATUS msg exchange could be achieved.

Can be used together with the devp2p:FIRST_PEER debugger.

Returns

void

Defined in

packages/devp2p/src/rlpx/peer.ts:689


_getProtocol

_getProtocol(code): undefined | ProtocolDescriptor

Returns either a protocol object with a protocol parameter reference to this Peer instance or to a subprotocol instance (e.g. ETH) (depending on the code provided)

Parameters

Name Type
code number

Returns

undefined | ProtocolDescriptor

Defined in

packages/devp2p/src/rlpx/peer.ts:651


_handleAck

_handleAck(): void

ACK message received

Returns

void

Defined in

packages/devp2p/src/rlpx/peer.ts:328


_handleAuth

_handleAuth(): void

AUTH message received

Returns

void

Defined in

packages/devp2p/src/rlpx/peer.ts:303


_handleBody

_handleBody(): void

Handle message body

Returns

void

Defined in

packages/devp2p/src/rlpx/peer.ts:516


_handleDisconnect

_handleDisconnect(payload): void

DISCONNECT message received

Parameters

Name Type
payload any

Returns

void

Defined in

packages/devp2p/src/rlpx/peer.ts:440


_handleHeader

_handleHeader(): void

Handle message header

Returns

void

Defined in

packages/devp2p/src/rlpx/peer.ts:497


_handleHello

_handleHello(payload): void

HELLO message received

Parameters

Name Type
payload any

Returns

void

Defined in

packages/devp2p/src/rlpx/peer.ts:359


_handleMessage

_handleMessage(code, msg): void

Message handling, called from a SubProtocol context

Parameters

Name Type
code PREFIXES
msg Uint8Array

Returns

void

Defined in

packages/devp2p/src/rlpx/peer.ts:477


_handlePing

_handlePing(): void

PING message received

Returns

void

Defined in

packages/devp2p/src/rlpx/peer.ts:461


_handlePong

_handlePong(): void

PONG message received

Returns

void

Defined in

packages/devp2p/src/rlpx/peer.ts:468


_onSocketClose

_onSocketClose(): void

React to socket being closed

Returns

void

Defined in

packages/devp2p/src/rlpx/peer.ts:638


_onSocketData

_onSocketData(data): void

Process socket data

Parameters

Name Type
data Uint8Array

Returns

void

Defined in

packages/devp2p/src/rlpx/peer.ts:608


_sendAck

_sendAck(): void

Send ACK message

Returns

void

Defined in

packages/devp2p/src/rlpx/peer.ts:170


_sendAuth

_sendAuth(): void

Send AUTH message

Returns

void

Defined in

packages/devp2p/src/rlpx/peer.ts:149


_sendDisconnect

_sendDisconnect(reason): void

Send DISCONNECT message

Parameters

Name Type
reason DISCONNECT_REASON

Returns

void

Defined in

packages/devp2p/src/rlpx/peer.ts:253


_sendHello

_sendHello(): void

Send HELLO message

Returns

void

Defined in

packages/devp2p/src/rlpx/peer.ts:217


_sendMessage

_sendMessage(code, data): undefined | boolean

Create message HEADER and BODY and send to socket Also called from SubProtocol context

Parameters

Name Type
code number
data Uint8Array

Returns

undefined | boolean

Defined in

packages/devp2p/src/rlpx/peer.ts:197


_sendPing

_sendPing(): void

Send PING message

Returns

void

Defined in

packages/devp2p/src/rlpx/peer.ts:272


_sendPong

_sendPong(): void

Send PONG message

Returns

void

Defined in

packages/devp2p/src/rlpx/peer.ts:290


disconnect

disconnect(reason?): void

Parameters

Name Type Default value
reason DISCONNECT_REASON DISCONNECT_REASON.DISCONNECT_REQUESTED

Returns

void

Defined in

packages/devp2p/src/rlpx/peer.ts:679


getDisconnectPrefix

getDisconnectPrefix(code): string

Parameters

Name Type
code DISCONNECT_REASON

Returns

string

Defined in

packages/devp2p/src/rlpx/peer.ts:675


getHelloMessage

getHelloMessage(): null | Hello

Returns

null | Hello

Defined in

packages/devp2p/src/rlpx/peer.ts:663


getId

getId(): null | Uint8Array

Returns

null | Uint8Array

Defined in

packages/devp2p/src/rlpx/peer.ts:658


getMsgPrefix

getMsgPrefix(code): string

Parameters

Name Type
code PREFIXES

Returns

string

Defined in

packages/devp2p/src/rlpx/peer.ts:671


getProtocols

getProtocols(): Protocol[]

Returns

Protocol[]

Defined in

packages/devp2p/src/rlpx/peer.ts:667