@savid/rlpx-pest
Version:
Get the [status](https://github.com/ethereum/devp2p/blob/master/caps/eth.md#status-0x00) of a [RLPx](https://github.com/ethereum/devp2p/blob/master/rlpx.md) peer via the [eth/66](https://eips.ethereum.org/EIPS/eip-2481) protocol.
61 lines (60 loc) • 2.11 kB
TypeScript
/// <reference types="node" resolution-mode="require"/>
/// <reference types="node" resolution-mode="require"/>
import EventEmitter from 'events';
import { PREFIXES, DISCONNECT_REASONS, ProtocolDescriptor } from '@ethereumjs/devp2p';
import { NestedBufferArray } from '@ethereumjs/util';
import { ETH66Status } from './eth66.js';
export declare class PeerError extends Error {
code: ErrorCode;
constructor(message: string, code: ErrorCode);
}
export declare enum ErrorCode {
INITIAL_SOCKET_CONNECT_FAILED = "INITIAL_SOCKET_CONNECT_FAILED",
SOCKET_ERROR = "SOCKET_ERROR",
SOCKET_CLOSED = "SOCKET_CLOSED",
INCOMING_DATA_STATE = "INCOMING_DATA_STATE",
INVALID_HEADER_SIZE = "INVALID_HEADER_SIZE",
SEND_HELLO_MESSAGE_FAILED = "SEND_HELLO_MESSAGE_FAILED",
EMPTY_BODY_MESSAGE = "EMPTY_BODY_MESSAGE",
BODY_PARSE_FAILED = "BODY_PARSE_FAILED",
PEER_DISCONNECTED = "PEER_DISCONNECTED"
}
declare interface Peer {
on(event: 'err', listener: (error: PeerError) => void): this;
on(event: 'status', listener: (data: ETH66Status) => void): this;
on(event: 'client', listener: (data: string) => void): this;
}
declare class Peer extends EventEmitter {
private id;
private remoteId;
private host;
private port;
private privateKey;
private eciesSession;
private state;
private socket;
private socketData;
private socketNextPacketSize;
private hello?;
private protocols;
private capabilities;
constructor({ remoteId, host, port }: {
remoteId: Buffer;
host: string;
port: number;
});
destroy(): void;
init(): void;
handleData(data: Buffer): void;
sendAuth(): void;
handleAck(): void;
handleHeader(): void;
handleMessage(code: PREFIXES, msg: NestedBufferArray): void;
sendHello(): void;
sendMessage(code: number, data: Buffer): boolean;
sendDisconnect(reason: DISCONNECT_REASONS): void;
getProtocol(code: number): ProtocolDescriptor | undefined;
handleBody(): void;
handleHello(payload: NestedBufferArray): void;
}
export default Peer;