File tree Expand file tree Collapse file tree 1 file changed +4
-3
lines changed Expand file tree Collapse file tree 1 file changed +4
-3
lines changed Original file line number Diff line number Diff line change @@ -2,24 +2,25 @@ import LRUCache from 'lru-cache'
2
2
import { debug as createDebugLogger } from 'debug'
3
3
import { KBucket } from './kbucket'
4
4
import { formatLogId } from '../util'
5
+ import { PeerInfo } from './dpt'
5
6
6
7
const debug = createDebugLogger ( 'devp2p:dpt:ban-list' )
7
8
const verbose = createDebugLogger ( 'verbose' ) . enabled
8
9
9
10
export class BanList {
10
- private lru : LRUCache < any , boolean >
11
+ private lru : LRUCache < string , boolean >
11
12
constructor ( ) {
12
13
this . lru = new LRUCache ( { max : 30000 } ) // 10k should be enough (each peer obj can has 3 keys)
13
14
}
14
15
15
- add ( obj : any , maxAge ?: number ) {
16
+ add ( obj : string | Buffer | PeerInfo , maxAge ?: number ) {
16
17
for ( const key of KBucket . getKeys ( obj ) ) {
17
18
this . lru . set ( key , true , maxAge )
18
19
debug ( `Added peer ${ formatLogId ( key , verbose ) } , size: ${ this . lru . length } ` )
19
20
}
20
21
}
21
22
22
- has ( obj : any ) : boolean {
23
+ has ( obj : string | Buffer | PeerInfo ) : boolean {
23
24
return KBucket . getKeys ( obj ) . some ( ( key : string ) => Boolean ( this . lru . get ( key ) ) )
24
25
}
25
26
}
You can’t perform that action at this time.
0 commit comments