This repository was archived by the owner on Dec 10, 2020. It is now read-only.
File tree Expand file tree Collapse file tree 8 files changed +12
-8
lines changed Expand file tree Collapse file tree 8 files changed +12
-8
lines changed Original file line number Diff line number Diff line change @@ -77,6 +77,7 @@ export class PeerPool extends EventEmitter {
77
77
} )
78
78
} )
79
79
this . opened = true
80
+ // eslint-disable-next-line @typescript-eslint/await-thenable
80
81
this . _statusCheckInterval = setInterval ( await this . _statusCheck . bind ( this ) , 20000 )
81
82
}
82
83
@@ -122,7 +123,7 @@ export class PeerPool extends EventEmitter {
122
123
* @param [filterFn] filter function to apply before finding idle peers
123
124
* @return {Peer }
124
125
*/
125
- idle ( filterFn = ( peer : Peer ) => true ) : Peer {
126
+ idle ( filterFn = ( _peer : Peer ) => true ) : Peer {
126
127
const idle = this . peers . filter ( ( p : any ) => p . idle && filterFn ( p ) )
127
128
const index = Math . floor ( Math . random ( ) * idle . length )
128
129
return idle [ index ]
@@ -141,7 +142,7 @@ export class PeerPool extends EventEmitter {
141
142
this . emit ( `message:${ protocol } ` , message , peer )
142
143
}
143
144
} )
144
- peer . on ( 'error' , ( error : Error , protocol : string ) => {
145
+ peer . on ( 'error' , ( error : Error ) => {
145
146
if ( this . pool . get ( peer . id ) ) {
146
147
this . logger . warn ( `Peer error: ${ error } ${ peer } ` )
147
148
this . ban ( peer )
Original file line number Diff line number Diff line change 1
1
import { EventEmitter } from 'events'
2
- import { Message , Protocol } from '../protocol/protocol'
2
+ import { Protocol } from '../protocol/protocol'
3
3
import { Peer } from '../peer/peer'
4
4
import { Sender } from './sender'
5
5
Original file line number Diff line number Diff line change @@ -57,6 +57,7 @@ export class FlowControl {
57
57
const params = this . in . get ( peer . id ) || { ble : bl }
58
58
if ( params . last ) {
59
59
// recharge BLE at rate of MRR when less than BL
60
+ // eslint-disable-next-line @typescript-eslint/restrict-plus-operands
60
61
params . ble = Math . min ( params . ble + mrr * ( now - params . last ) , bl )
61
62
}
62
63
params . last = now
@@ -78,10 +79,12 @@ export class FlowControl {
78
79
const now = Date . now ( )
79
80
const params = this . out . get ( peer . id ) || { }
80
81
if ( params . bv && params . last ) {
82
+ // eslint-disable-next-line @typescript-eslint/restrict-plus-operands
81
83
params . bv = Math . min ( params . bv + this . mrr * ( now - params . last ) , this . bl )
82
84
} else {
83
85
params . bv = this . bl
84
86
}
87
+ // eslint-disable-next-line @typescript-eslint/restrict-plus-operands
85
88
params . bv -= this . mrc [ messageName ] . base + this . mrc [ messageName ] . req * count
86
89
params . last = now
87
90
if ( params . bv < 0 ) {
Original file line number Diff line number Diff line change @@ -42,6 +42,7 @@ export class Libp2pSender extends Sender {
42
42
this . connection ,
43
43
catcher ( ( e : Error ) => this . error ( e ) ) ,
44
44
pull . drain ( ( message : any ) => {
45
+ // eslint-disable-next-line prefer-const
45
46
let [ code , payload ] : any = rlp . decode ( message )
46
47
code = bufferToInt ( code )
47
48
if ( code === 0 ) {
Original file line number Diff line number Diff line change @@ -127,7 +127,7 @@ export class Protocol extends EventEmitter {
127
127
* @param {Object } status status message payload
128
128
* @return {Object }
129
129
*/
130
- decodeStatus ( status : any ) : any {
130
+ decodeStatus ( _status : any ) : any {
131
131
throw new Error ( 'Unimplemented' )
132
132
}
133
133
Original file line number Diff line number Diff line change @@ -30,7 +30,7 @@ export class Sender extends EventEmitter {
30
30
* @protected
31
31
* @param {Object } status
32
32
*/
33
- sendStatus ( status : any ) {
33
+ sendStatus ( _status : any ) {
34
34
throw new Error ( 'Unimplemented' )
35
35
}
36
36
@@ -40,7 +40,7 @@ export class Sender extends EventEmitter {
40
40
* @param {number } code message code
41
41
* @param {Array|Buffer } rlpEncodedData rlp encoded message payload
42
42
*/
43
- sendMessage ( code : number , rlpEncodedData : any [ ] | Buffer ) {
43
+ sendMessage ( _code : number , _rlpEncodedData : any [ ] | Buffer ) {
44
44
throw new Error ( 'Unimplemented' )
45
45
}
46
46
}
Original file line number Diff line number Diff line change 1
1
import { Server } from './server'
2
- import { Protocol } from './../protocol/protocol'
3
2
const { randomBytes } = require ( 'crypto' )
4
3
import { RLPx as Devp2pRLPx , Peer as Devp2pRLPxPeer , DPT as Devp2pDPT } from 'ethereumjs-devp2p'
5
4
import { RlpxPeer } from '../peer/rlpxpeer'
Original file line number Diff line number Diff line change @@ -91,7 +91,7 @@ export class Server extends EventEmitter {
91
91
* @param maxAge how long to ban peer
92
92
* @return {Promise }
93
93
*/
94
- ban ( peerId : string , maxAge : number ) {
94
+ ban ( _peerId : string , _maxAge : number ) {
95
95
// don't do anything by default
96
96
}
97
97
}
You can’t perform that action at this time.
0 commit comments