Skip to content

Commit 9fe77d6

Browse files
committed
devp2p -> DPT: added types for DPT ban-list
1 parent b3b0e78 commit 9fe77d6

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

packages/devp2p/src/dpt/ban-list.ts

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,24 +2,25 @@ import LRUCache from 'lru-cache'
22
import { debug as createDebugLogger } from 'debug'
33
import { KBucket } from './kbucket'
44
import { formatLogId } from '../util'
5+
import { PeerInfo } from './dpt'
56

67
const debug = createDebugLogger('devp2p:dpt:ban-list')
78
const verbose = createDebugLogger('verbose').enabled
89

910
export class BanList {
10-
private lru: LRUCache<any, boolean>
11+
private lru: LRUCache<string, boolean>
1112
constructor() {
1213
this.lru = new LRUCache({ max: 30000 }) // 10k should be enough (each peer obj can has 3 keys)
1314
}
1415

15-
add(obj: any, maxAge?: number) {
16+
add(obj: string | Buffer | PeerInfo, maxAge?: number) {
1617
for (const key of KBucket.getKeys(obj)) {
1718
this.lru.set(key, true, maxAge)
1819
debug(`Added peer ${formatLogId(key, verbose)}, size: ${this.lru.length}`)
1920
}
2021
}
2122

22-
has(obj: any): boolean {
23+
has(obj: string | Buffer | PeerInfo): boolean {
2324
return KBucket.getKeys(obj).some((key: string) => Boolean(this.lru.get(key)))
2425
}
2526
}

0 commit comments

Comments
 (0)