ethereumjs-client › "net/peerpool" › PeerPool
Pool of connected peers
memberof
module:net
emits
connected
emits
disconnected
emits
banned
emits
added
emits
removed
emits
message
emits
message:{protocol}
emits
error
-
EventEmitter
↳ PeerPool
- _statusCheck
- add
- addListener
- ban
- close
- connected
- contains
- disconnected
- emit
- eventNames
- getMaxListeners
- idle
- init
- listenerCount
- listeners
- off
- on
- once
- open
- prependListener
- prependOnceListener
- rawListeners
- remove
- removeAllListeners
- removeListener
- setMaxListeners
- listenerCount
+ new PeerPool(options
: PeerPoolOptions): PeerPool
Overrides void
Defined in lib/net/peerpool.ts:33
Create new peer pool
Parameters:
Name | Type | Description |
---|---|---|
options |
PeerPoolOptions | constructor parameters |
Returns: PeerPool
• config: Config
Defined in lib/net/peerpool.ts:28
▪ defaultMaxListeners: number
Inherited from Sender.defaultMaxListeners
Defined in node_modules/@types/node/events.d.ts:45
▪ 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.
• get peers(): Peer[]
Defined in lib/net/peerpool.ts:90
Connected peers
Returns: Peer[]
• get size(): number
Defined in lib/net/peerpool.ts:99
Number of peers in pool
type
{number}
Returns: number
▸ _statusCheck(): Promise‹void›
Defined in lib/net/peerpool.ts:202
Peer pool status check on a repeated interval
Returns: Promise‹void›
▸ add(peer?
: Peer): void
Defined in lib/net/peerpool.ts:179
Add peer to pool
emits
added
emits
message
emits
message:{protocol}
Parameters:
Name | Type |
---|---|
peer? |
Peer |
Returns: void
▸ 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
▸ ban(peer
: Peer, maxAge
: number): void
Defined in lib/net/peerpool.ts:162
Ban peer from being added to the pool for a period of time
emits
banned
Parameters:
Name | Type | Default | Description |
---|---|---|---|
peer |
Peer | - | - |
maxAge |
number | 60000 | ban period in milliseconds |
Returns: void
▸ close(): Promise‹void›
Defined in lib/net/peerpool.ts:81
Close pool
Returns: Promise‹void›
▸ connected(peer
: Peer): void
Defined in lib/net/peerpool.ts:130
Handler for peer connections
Parameters:
Name | Type | Description |
---|---|---|
peer |
Peer |
Returns: void
▸ contains(peer
: Peer | string): boolean
Defined in lib/net/peerpool.ts:107
Return true if pool contains the specified peer
Parameters:
Name | Type | Description |
---|---|---|
peer |
Peer | string | object or peer id |
Returns: boolean
▸ disconnected(peer
: Peer): void
Defined in lib/net/peerpool.ts:152
Handler for peer disconnections
Parameters:
Name | Type | Description |
---|---|---|
peer |
Peer |
Returns: void
▸ emit(event
: string | symbol, ...args
: any[]): boolean
Defined in node_modules/@types/node/events.d.ts:72
Parameters:
Name | Type |
---|---|
event |
string | symbol |
...args |
any[] |
Returns: boolean
▸ eventNames(): Array‹string | symbol›
Inherited from Sender.eventNames
Defined in node_modules/@types/node/events.d.ts:77
Returns: Array‹string | symbol›
▸ getMaxListeners(): number
Inherited from Sender.getMaxListeners
Defined in node_modules/@types/node/events.d.ts:69
Returns: number
▸ idle(filterFn
: (Anonymous function)): Peer
Defined in lib/net/peerpool.ts:119
Returns a random idle peer from the pool
Parameters:
Name | Type | Default |
---|---|---|
filterFn |
(Anonymous function) | (_peer: Peer) => true |
Returns: Peer
▸ init(): void
Defined in lib/net/peerpool.ts:52
Returns: void
▸ 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(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(event
: string | symbol, listener
: function): this
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(event
: string | symbol, listener
: function): this
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(event
: string | symbol, listener
: function): this
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(): Promise‹boolean | void›
Defined in lib/net/peerpool.ts:60
Open pool
Returns: Promise‹boolean | void›
▸ 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(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(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[]
▸ remove(peer?
: Peer): void
Defined in lib/net/peerpool.ts:191
Remove peer from pool
emits
removed
Parameters:
Name | Type |
---|---|
peer? |
Peer |
Returns: void
▸ 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(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(n
: number): this
Inherited from Sender.setMaxListeners
Defined in node_modules/@types/node/events.d.ts:68
Parameters:
Name | Type |
---|---|
n |
number |
Returns: this
▸ 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