diff --git a/packages/core/src/lib/base_protocol.ts b/packages/core/src/lib/base_protocol.ts index 8ec5b1af9a..740298ae0a 100644 --- a/packages/core/src/lib/base_protocol.ts +++ b/packages/core/src/lib/base_protocol.ts @@ -46,7 +46,6 @@ export class BaseProtocol implements IBaseProtocolCore { return this.streamManager.getStream(peer); } - //TODO: move to SDK /** * Returns known peers from the address book (`libp2p.peerStore`) that support * the class protocol. Waku may or may not be currently connected to these @@ -56,17 +55,12 @@ export class BaseProtocol implements IBaseProtocolCore { return getPeersForProtocol(this.components.peerStore, [this.multicodec]); } - public async connectedPeers(withOpenStreams = false): Promise { + public async connectedPeers(): Promise { const peers = await this.allPeers(); return peers.filter((peer) => { const connections = this.components.connectionManager.getConnections( peer.id ); - if (withOpenStreams) { - return connections.some((c) => - c.streams.some((s) => s.protocol === this.multicodec) - ); - } return connections.length > 0; }); } diff --git a/packages/sdk/src/protocols/base_protocol.ts b/packages/sdk/src/protocols/base_protocol.ts index f98aed3324..7101a1789f 100644 --- a/packages/sdk/src/protocols/base_protocol.ts +++ b/packages/sdk/src/protocols/base_protocol.ts @@ -38,7 +38,6 @@ export class BaseProtocolSDK implements IBaseProtocolSDK { this.log.info( `Initializing BaseProtocolSDK with numPeersToUse: ${this.numPeersToUse}, maintainPeersInterval: ${maintainPeersInterval}ms` ); - // void this.setupEventListeners(); void this.startMaintainPeersInterval(maintainPeersInterval); } @@ -83,18 +82,6 @@ export class BaseProtocolSDK implements IBaseProtocolSDK { } } - //TODO: validate if adding event listeners for peer connect and disconnect is needed - // private setupEventListeners(): void { - // this.core.addLibp2pEventListener( - // "peer:connect", - // () => void this.maintainPeers() - // ); - // this.core.addLibp2pEventListener( - // "peer:disconnect", - // () => void this.maintainPeers() - // ); - // } - /** * Checks if there are sufficient peers to send a message to. * If `forceUseAllPeers` is `false` (default), returns `true` if there are any connected peers. @@ -162,7 +149,6 @@ export class BaseProtocolSDK implements IBaseProtocolSDK { `Starting maintain peers interval with ${interval}ms interval` ); try { - // await this.maintainPeers(); this.maintainPeersIntervalId = setInterval(() => { this.log.debug("Running scheduled peer maintenance"); this.maintainPeers().catch((error) => { diff --git a/packages/sdk/src/protocols/filter/subscription_manager.ts b/packages/sdk/src/protocols/filter/subscription_manager.ts index 4300246624..5a1334b767 100644 --- a/packages/sdk/src/protocols/filter/subscription_manager.ts +++ b/packages/sdk/src/protocols/filter/subscription_manager.ts @@ -144,6 +144,7 @@ export class SubscriptionManager implements ISubscriptionSDK { } public async ping(peerId?: PeerId): Promise { + log.info("Sending keep-alive ping"); const peers = peerId ? [peerId] : this.getPeers().map((peer) => peer.id); const promises = peers.map((peerId) => this.pingSpecificPeer(peerId)); @@ -303,7 +304,6 @@ export class SubscriptionManager implements ISubscriptionSDK { } this.keepAliveTimer = setInterval(() => { - log.info("Sending keep-alive ping"); void this.ping() .then(() => log.info("Keep-alive ping successful")) .catch((error) => log.error("Error in keep-alive ping cycle:", error));