Skip to content

Commit

Permalink
Simplify libp2p type.
Browse files Browse the repository at this point in the history
  • Loading branch information
saul-jb committed Jan 9, 2024
1 parent f1d2032 commit 4129df2
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions src/advertisers/dht.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import drain from 'it-drain'
import type { Advertiser } from '../index.js'
import type { ContentRouting } from '@libp2p/interface/content-routing'
import type { PeerId } from '@libp2p/interface/peer-id'
import type { KadDHT } from '@libp2p/kad-dht'
import type { Libp2p } from 'libp2p'
import type { CID } from 'multiformats/cid'

export interface CreateEphemeralKadDHT {
Expand All @@ -22,7 +22,7 @@ const collaborate = (createEphemeralKadDHT: CreateEphemeralKadDHT): Advertiser['
}
}

const findCollaborators = (libp2p: Libp2p): Advertiser['findCollaborators'] =>
const findCollaborators = (libp2p: { contentRouting: ContentRouting }): Advertiser['findCollaborators'] =>
async function * (dcid: CID): AsyncIterable<PeerId> {
try {
for await (const peerInfo of libp2p.contentRouting.findProviders(dcid)) {
Expand All @@ -34,7 +34,7 @@ const findCollaborators = (libp2p: Libp2p): Advertiser['findCollaborators'] =>
}
}

export function dhtAdvertiser (libp2p: Libp2p, createEphemeralKadDHT: CreateEphemeralKadDHT): Advertiser {
export function dhtAdvertiser (libp2p: { contentRouting: ContentRouting }, createEphemeralKadDHT: CreateEphemeralKadDHT): Advertiser {
return {
collaborate: collaborate(createEphemeralKadDHT),
findCollaborators: findCollaborators(libp2p)
Expand Down

0 comments on commit 4129df2

Please sign in to comment.