Skip to content

Commit cfae9c5

Browse files
committed
export libp2p node
1 parent b74e620 commit cfae9c5

2 files changed

Lines changed: 9 additions & 0 deletions

File tree

src/services/providers/BaseProvider.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -472,6 +472,10 @@ export class BaseProvider {
472472
return this.p2pProvider.setupP2P(config)
473473
}
474474

475+
public getLibp2pNode() {
476+
return this.p2pProvider.getLibp2pNode()
477+
}
478+
475479
public async getDiscoveredNodes(): Promise<
476480
Array<{ peerId: string; multiaddrs: string[] }>
477481
> {

src/services/providers/P2pProvider.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -148,6 +148,11 @@ export class P2pProvider {
148148
throw new Error(`No multiaddrs found for peer id ${peerId}`)
149149
}
150150

151+
/** Returns the underlying libp2p node instance, or null if P2P is not initialized. */
152+
public getLibp2pNode(): Libp2p | null {
153+
return this.libp2pNode ?? null
154+
}
155+
151156
/** Returns all peers known to the peerStore (discovered via bootstrap, DHT, or connections). */
152157
public async getDiscoveredNodes(): Promise<
153158
Array<{ peerId: string; multiaddrs: string[] }>

0 commit comments

Comments
 (0)