From 8291f4d010740cd271d2d68937fa45ab3ef6ab17 Mon Sep 17 00:00:00 2001 From: Danish Arora Date: Tue, 24 Sep 2024 11:27:15 +0530 Subject: [PATCH] fix: build chore: update lock --- package-lock.json | 12 +++++++++++- packages/core/src/lib/base_protocol.ts | 8 ++++---- packages/core/src/lib/metadata/index.ts | 2 +- .../src/peer-exchange/waku_peer_exchange.ts | 2 +- 4 files changed, 17 insertions(+), 7 deletions(-) diff --git a/package-lock.json b/package-lock.json index cb8799416c..204126a6e3 100644 --- a/package-lock.json +++ b/package-lock.json @@ -11822,6 +11822,15 @@ "integrity": "sha512-csOlWGAcRFJaI6m+F2WKdnMKr4HhdhFVBk0H/QbJFMCr+uO2kwohwXQPxw/9OCxp05r5ghVBFSyioixx3gfkNQ==", "license": "MIT" }, + "node_modules/async-mutex": { + "version": "0.5.0", + "resolved": "https://registry.npmjs.org/async-mutex/-/async-mutex-0.5.0.tgz", + "integrity": "sha512-1A94B18jkJ3DYq284ohPxoXbfTA5HsQ7/Mf4DEhcyLx3Bz27Rh59iScbB6EPiP+B+joue6YCxcMXSbFC1tZKwA==", + "license": "MIT", + "dependencies": { + "tslib": "^2.4.0" + } + }, "node_modules/asynckit": { "version": "0.4.0", "resolved": "https://registry.npmjs.org/asynckit/-/asynckit-0.4.0.tgz", @@ -39397,7 +39406,7 @@ "license": "MIT OR Apache-2.0", "dependencies": { "@chainsafe/libp2p-noise": "^15.1.0", - "@libp2p/bootstrap": "^10.1.2", + "@libp2p/bootstrap": "^10", "@libp2p/identify": "^2.1.2", "@libp2p/mplex": "^10.1.2", "@libp2p/ping": "^1.1.2", @@ -39409,6 +39418,7 @@ "@waku/message-hash": "0.1.16", "@waku/proto": "^0.0.8", "@waku/utils": "0.0.20", + "async-mutex": "^0.5.0", "libp2p": "^1.8.1" }, "devDependencies": { diff --git a/packages/core/src/lib/base_protocol.ts b/packages/core/src/lib/base_protocol.ts index 4b3b7c5a14..bcc6ff4ec4 100644 --- a/packages/core/src/lib/base_protocol.ts +++ b/packages/core/src/lib/base_protocol.ts @@ -22,7 +22,7 @@ export class BaseProtocol implements IBaseProtocolCore { protected constructor( public multicodec: string, - private components: Libp2pComponents, + protected components: Libp2pComponents, private log: Logger, public readonly pubsubTopics: PubsubTopic[] ) { @@ -52,9 +52,9 @@ export class BaseProtocol implements IBaseProtocolCore { * the class protocol. Waku may or may not be currently connected to these * peers. */ - // public async allPeers(): Promise { - // return getPeersForProtocol(this.peerStore, [this.multicodec]); - // } + public async allPeers(): Promise { + return getPeersForProtocol(this.components.peerStore, [this.multicodec]); + } public async connectedPeers(withOpenStreams = false): Promise { const peers = await this.allPeers(); diff --git a/packages/core/src/lib/metadata/index.ts b/packages/core/src/lib/metadata/index.ts index 3dbf7ed8a2..1744450c7b 100644 --- a/packages/core/src/lib/metadata/index.ts +++ b/packages/core/src/lib/metadata/index.ts @@ -45,7 +45,7 @@ class Metadata extends BaseProtocol implements IMetadata { pubsubTopicsToShardInfo(this.pubsubTopics) ); - const peer = await this.peerStore.get(peerId); + const peer = await this.libp2pComponents.peerStore.get(peerId); if (!peer) { return { shardInfo: null, diff --git a/packages/discovery/src/peer-exchange/waku_peer_exchange.ts b/packages/discovery/src/peer-exchange/waku_peer_exchange.ts index 43d337728d..6030b86f76 100644 --- a/packages/discovery/src/peer-exchange/waku_peer_exchange.ts +++ b/packages/discovery/src/peer-exchange/waku_peer_exchange.ts @@ -47,7 +47,7 @@ export class WakuPeerExchange extends BaseProtocol implements IPeerExchange { numPeers: BigInt(numPeers) }); - const peer = await this.peerStore.get(peerId); + const peer = await this.components.peerStore.get(peerId); if (!peer) { return { peerInfos: null,