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

Commit 39fe168

Browse files
committed
Lint lib/net
1 parent ecfd653 commit 39fe168

File tree

8 files changed

+12
-8
lines changed

8 files changed

+12
-8
lines changed

lib/net/peerpool.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,7 @@ export class PeerPool extends EventEmitter {
7777
})
7878
})
7979
this.opened = true
80+
// eslint-disable-next-line @typescript-eslint/await-thenable
8081
this._statusCheckInterval = setInterval(await this._statusCheck.bind(this), 20000)
8182
}
8283

@@ -122,7 +123,7 @@ export class PeerPool extends EventEmitter {
122123
* @param [filterFn] filter function to apply before finding idle peers
123124
* @return {Peer}
124125
*/
125-
idle(filterFn = (peer: Peer) => true): Peer {
126+
idle(filterFn = (_peer: Peer) => true): Peer {
126127
const idle = this.peers.filter((p: any) => p.idle && filterFn(p))
127128
const index = Math.floor(Math.random() * idle.length)
128129
return idle[index]
@@ -141,7 +142,7 @@ export class PeerPool extends EventEmitter {
141142
this.emit(`message:${protocol}`, message, peer)
142143
}
143144
})
144-
peer.on('error', (error: Error, protocol: string) => {
145+
peer.on('error', (error: Error) => {
145146
if (this.pool.get(peer.id)) {
146147
this.logger.warn(`Peer error: ${error} ${peer}`)
147148
this.ban(peer)

lib/net/protocol/boundprotocol.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import { EventEmitter } from 'events'
2-
import { Message, Protocol } from '../protocol/protocol'
2+
import { Protocol } from '../protocol/protocol'
33
import { Peer } from '../peer/peer'
44
import { Sender } from './sender'
55

lib/net/protocol/flowcontrol.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,7 @@ export class FlowControl {
5757
const params = this.in.get(peer.id) || { ble: bl }
5858
if (params.last) {
5959
// recharge BLE at rate of MRR when less than BL
60+
// eslint-disable-next-line @typescript-eslint/restrict-plus-operands
6061
params.ble = Math.min(params.ble + mrr * (now - params.last), bl)
6162
}
6263
params.last = now
@@ -78,10 +79,12 @@ export class FlowControl {
7879
const now = Date.now()
7980
const params = this.out.get(peer.id) || {}
8081
if (params.bv && params.last) {
82+
// eslint-disable-next-line @typescript-eslint/restrict-plus-operands
8183
params.bv = Math.min(params.bv + this.mrr * (now - params.last), this.bl)
8284
} else {
8385
params.bv = this.bl
8486
}
87+
// eslint-disable-next-line @typescript-eslint/restrict-plus-operands
8588
params.bv -= this.mrc[messageName].base + this.mrc[messageName].req * count
8689
params.last = now
8790
if (params.bv < 0) {

lib/net/protocol/libp2psender.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@ export class Libp2pSender extends Sender {
4242
this.connection,
4343
catcher((e: Error) => this.error(e)),
4444
pull.drain((message: any) => {
45+
// eslint-disable-next-line prefer-const
4546
let [code, payload]: any = rlp.decode(message)
4647
code = bufferToInt(code)
4748
if (code === 0) {

lib/net/protocol/protocol.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -127,7 +127,7 @@ export class Protocol extends EventEmitter {
127127
* @param {Object} status status message payload
128128
* @return {Object}
129129
*/
130-
decodeStatus(status: any): any {
130+
decodeStatus(_status: any): any {
131131
throw new Error('Unimplemented')
132132
}
133133

lib/net/protocol/sender.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ export class Sender extends EventEmitter {
3030
* @protected
3131
* @param {Object} status
3232
*/
33-
sendStatus(status: any) {
33+
sendStatus(_status: any) {
3434
throw new Error('Unimplemented')
3535
}
3636

@@ -40,7 +40,7 @@ export class Sender extends EventEmitter {
4040
* @param {number} code message code
4141
* @param {Array|Buffer} rlpEncodedData rlp encoded message payload
4242
*/
43-
sendMessage(code: number, rlpEncodedData: any[] | Buffer) {
43+
sendMessage(_code: number, _rlpEncodedData: any[] | Buffer) {
4444
throw new Error('Unimplemented')
4545
}
4646
}

lib/net/server/rlpxserver.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
import { Server } from './server'
2-
import { Protocol } from './../protocol/protocol'
32
const { randomBytes } = require('crypto')
43
import { RLPx as Devp2pRLPx, Peer as Devp2pRLPxPeer, DPT as Devp2pDPT } from 'ethereumjs-devp2p'
54
import { RlpxPeer } from '../peer/rlpxpeer'

lib/net/server/server.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,7 @@ export class Server extends EventEmitter {
9191
* @param maxAge how long to ban peer
9292
* @return {Promise}
9393
*/
94-
ban(peerId: string, maxAge: number) {
94+
ban(_peerId: string, _maxAge: number) {
9595
// don't do anything by default
9696
}
9797
}

0 commit comments

Comments
 (0)