Skip to content
This repository has been archived by the owner on Dec 10, 2020. It is now read-only.

Latest commit

 

History

History
632 lines (356 loc) · 14.9 KB

_net_protocol_protocol_.protocol.md

File metadata and controls

632 lines (356 loc) · 14.9 KB

ethereumjs-client"net/protocol/protocol"Protocol

Class: Protocol

Base class for all wire protocols

memberof module:net/protocol

Hierarchy

Index

Constructors

Properties

Accessors

Methods

Constructors

constructor

+ new Protocol(options: ProtocolOptions): Protocol

Overrides void

Defined in lib/net/protocol/protocol.ts:43

Create new protocol

Parameters:

Name Type
options ProtocolOptions

Returns: Protocol

Properties

config

config: Config

Defined in lib/net/protocol/protocol.ts:41


opened

opened: boolean

Defined in lib/net/protocol/protocol.ts:43


timeout

timeout: number

Defined in lib/net/protocol/protocol.ts:42


Static defaultMaxListeners

defaultMaxListeners: number

Inherited from Sender.defaultMaxListeners

Defined in node_modules/@types/node/events.d.ts:45


Static errorMonitor

errorMonitor: keyof symbol

Inherited from Sender.errorMonitor

Defined in node_modules/@types/node/events.d.ts:55

This symbol shall be used to install a listener for only monitoring 'error' events. Listeners installed using this symbol are called before the regular 'error' listeners are called.

Installing a listener using this symbol does not change the behavior once an 'error' event is emitted, therefore the process will still crash if no regular 'error' listener is installed.

Accessors

messages

get messages(): Message[]

Defined in lib/net/protocol/protocol.ts:113

Messages defined by this protocol

type {Protocol~Message[]}

Returns: Message[]


name

get name(): string

Defined in lib/net/protocol/protocol.ts:97

Abstract getter for name of protocol

type {string}

Returns: string


versions

get versions(): number[]

Defined in lib/net/protocol/protocol.ts:105

Protocol versions supported

type {number[]}

Returns: number[]

Methods

addListener

addListener(event: string | symbol, listener: function): this

Inherited from Sender.addListener

Defined in node_modules/@types/node/events.d.ts:62

Parameters:

event: string | symbol

listener: function

▸ (...args: any[]): void

Parameters:

Name Type
...args any[]

Returns: this


bind

bind(peer: Peer, sender: Sender): Promise‹BoundProtocol

Defined in lib/net/protocol/protocol.ts:171

Binds this protocol to a given peer using the specified sender to handle message communication.

Parameters:

Name Type Description
peer Peer peer
sender Sender sender

Returns: Promise‹BoundProtocol


Protected decode

decode(message: Message, payload: any): any

Defined in lib/net/protocol/protocol.ts:157

Decodes message payload

Parameters:

Name Type Description
message Message message definition
payload any message payload

Returns: any


decodeStatus

decodeStatus(_status: any): any

Defined in lib/net/protocol/protocol.ts:131

Decodes status message payload into a status object. Must be implemented by subclass.

Parameters:

Name Type
_status any

Returns: any


emit

emit(event: string | symbol, ...args: any[]): boolean

Inherited from Sender.emit

Defined in node_modules/@types/node/events.d.ts:72

Parameters:

Name Type
event string | symbol
...args any[]

Returns: boolean


Protected encode

encode(message: Message, args: any): any

Defined in lib/net/protocol/protocol.ts:142

Encodes message into proper format before sending

Parameters:

Name Type Description
message Message message definition
args any message arguments

Returns: any


encodeStatus

encodeStatus(): any

Defined in lib/net/protocol/protocol.ts:121

Encodes status into status message payload. Must be implemented by subclass.

Returns: any


eventNames

eventNames(): Array‹string | symbol›

Inherited from Sender.eventNames

Defined in node_modules/@types/node/events.d.ts:77

Returns: Array‹string | symbol›


getMaxListeners

getMaxListeners(): number

Inherited from Sender.getMaxListeners

Defined in node_modules/@types/node/events.d.ts:69

Returns: number


Private handshake

handshake(sender: Sender): Promise‹unknown›

Defined in lib/net/protocol/protocol.ts:71

Perform handshake given a sender from subclass.

Parameters:

Name Type
sender Sender

Returns: Promise‹unknown›


listenerCount

listenerCount(event: string | symbol): number

Inherited from Sender.listenerCount

Defined in node_modules/@types/node/events.d.ts:73

Parameters:

Name Type
event string | symbol

Returns: number


listeners

listeners(event: string | symbol): Function[]

Inherited from Sender.listeners

Defined in node_modules/@types/node/events.d.ts:70

Parameters:

Name Type
event string | symbol

Returns: Function[]


off

off(event: string | symbol, listener: function): this

Inherited from Sender.off

Defined in node_modules/@types/node/events.d.ts:66

Parameters:

event: string | symbol

listener: function

▸ (...args: any[]): void

Parameters:

Name Type
...args any[]

Returns: this


on

on(event: string | symbol, listener: function): this

Inherited from Sender.on

Defined in node_modules/@types/node/events.d.ts:63

Parameters:

event: string | symbol

listener: function

▸ (...args: any[]): void

Parameters:

Name Type
...args any[]

Returns: this


once

once(event: string | symbol, listener: function): this

Inherited from Sender.once

Defined in node_modules/@types/node/events.d.ts:64

Parameters:

event: string | symbol

listener: function

▸ (...args: any[]): void

Parameters:

Name Type
...args any[]

Returns: this


open

open(): Promise‹boolean | void›

Defined in lib/net/protocol/protocol.ts:62

Opens protocol and any associated dependencies

Returns: Promise‹boolean | void›


prependListener

prependListener(event: string | symbol, listener: function): this

Inherited from Sender.prependListener

Defined in node_modules/@types/node/events.d.ts:75

Parameters:

event: string | symbol

listener: function

▸ (...args: any[]): void

Parameters:

Name Type
...args any[]

Returns: this


prependOnceListener

prependOnceListener(event: string | symbol, listener: function): this

Inherited from Sender.prependOnceListener

Defined in node_modules/@types/node/events.d.ts:76

Parameters:

event: string | symbol

listener: function

▸ (...args: any[]): void

Parameters:

Name Type
...args any[]

Returns: this


rawListeners

rawListeners(event: string | symbol): Function[]

Inherited from Sender.rawListeners

Defined in node_modules/@types/node/events.d.ts:71

Parameters:

Name Type
event string | symbol

Returns: Function[]


removeAllListeners

removeAllListeners(event?: string | symbol): this

Inherited from Sender.removeAllListeners

Defined in node_modules/@types/node/events.d.ts:67

Parameters:

Name Type
event? string | symbol

Returns: this


removeListener

removeListener(event: string | symbol, listener: function): this

Inherited from Sender.removeListener

Defined in node_modules/@types/node/events.d.ts:65

Parameters:

event: string | symbol

listener: function

▸ (...args: any[]): void

Parameters:

Name Type
...args any[]

Returns: this


setMaxListeners

setMaxListeners(n: number): this

Inherited from Sender.setMaxListeners

Defined in node_modules/@types/node/events.d.ts:68

Parameters:

Name Type
n number

Returns: this


Static listenerCount

listenerCount(emitter: EventEmitter, event: string | symbol): number

Inherited from Sender.listenerCount

Defined in node_modules/@types/node/events.d.ts:44

deprecated since v4.0.0

Parameters:

Name Type
emitter EventEmitter
event string | symbol

Returns: number