1
1
import { DEFAULT_SESSION_MIN_PROVIDERS , DEFAULT_SESSION_MAX_PROVIDERS , InsufficientProvidersError } from '@helia/interface'
2
2
import { TypedEventEmitter , setMaxListeners } from '@libp2p/interface'
3
+ import { createScalableCuckooFilter } from '@libp2p/utils/filters'
3
4
import { Queue } from '@libp2p/utils/queue'
4
5
import { base64 } from 'multiformats/bases/base64'
5
6
import pDefer from 'p-defer'
6
- import { BloomFilter } from './bloom-filter.js'
7
7
import type { BlockBroker , BlockRetrievalOptions , CreateSessionOptions } from '@helia/interface'
8
8
import type { AbortOptions , ComponentLogger , Logger } from '@libp2p/interface'
9
+ import type { Filter } from '@libp2p/utils/filters'
9
10
import type { CID } from 'multiformats/cid'
10
11
import type { DeferredPromise } from 'p-defer'
11
12
import type { ProgressEvent } from 'progress-events'
@@ -31,7 +32,7 @@ export abstract class AbstractSession<Provider, RetrieveBlockProgressEvents exte
31
32
private readonly minProviders : number
32
33
private readonly maxProviders : number
33
34
public readonly providers : Provider [ ]
34
- private readonly evictionFilter : BloomFilter
35
+ private readonly evictionFilter : Filter
35
36
36
37
constructor ( components : AbstractSessionComponents , init : AbstractCreateSessionOptions ) {
37
38
super ( )
@@ -44,7 +45,7 @@ export abstract class AbstractSession<Provider, RetrieveBlockProgressEvents exte
44
45
this . minProviders = init . minProviders ?? DEFAULT_SESSION_MIN_PROVIDERS
45
46
this . maxProviders = init . maxProviders ?? DEFAULT_SESSION_MAX_PROVIDERS
46
47
this . providers = [ ]
47
- this . evictionFilter = BloomFilter . create ( this . maxProviders )
48
+ this . evictionFilter = createScalableCuckooFilter ( this . maxProviders )
48
49
}
49
50
50
51
async retrieve ( cid : CID , options : BlockRetrievalOptions < RetrieveBlockProgressEvents > = { } ) : Promise < Uint8Array > {
0 commit comments