Skip to content

Commit

Permalink
chore: address comments
Browse files Browse the repository at this point in the history
  • Loading branch information
danisharora099 committed Jul 10, 2024
1 parent 438ac03 commit 3516b43
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 12 deletions.
15 changes: 4 additions & 11 deletions packages/sdk/src/protocols/filter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -154,16 +154,9 @@ export class SubscriptionManager implements ISubscriptionSDK {
}

public async ping(peerId?: PeerId): Promise<SDKProtocolResult> {
if (peerId) {
const result = await this.pingSpecificPeer(peerId);
return result.failure
? { failures: [result.failure], successes: [] }
: { failures: [], successes: [result.success!] };
}
const peers = peerId ? [peerId] : this.getPeers().map((peer) => peer.id);

const promises = this.getPeers().map((peer) =>
this.pingSpecificPeer(peer.id)
);
const promises = peers.map((peerId) => this.pingSpecificPeer(peerId));
const results = await Promise.allSettled(promises);

return this.handleResult(results, "ping");
Expand Down Expand Up @@ -276,15 +269,15 @@ export class SubscriptionManager implements ISubscriptionSDK {

if (failures > this.maxPingFailures) {
try {
await this._renewPeer(peerId);
await this.renewAndSubscribePeer(peerId);
this.peerFailures.delete(peerId.toString());
} catch (error) {
log.error(`Failed to renew peer ${peerId.toString()}: ${error}.`);
}
}
}

private async _renewPeer(peerId: PeerId): Promise<Peer> {
private async renewAndSubscribePeer(peerId: PeerId): Promise<Peer> {
const newPeer = await this.renewPeer(peerId);
await this.protocol.subscribe(
this.pubsubTopic,
Expand Down
2 changes: 1 addition & 1 deletion packages/tests/tests/filter/peer_management.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ import {
teardownNodesWithRedundancy
} from "../filter/utils.js";

describe.only("Waku Filter: Peer Management: E2E", function () {
describe("Waku Filter: Peer Management: E2E", function () {
this.timeout(15000);
let waku: LightNode;
let serviceNodes: ServiceNodesFleet;
Expand Down

0 comments on commit 3516b43

Please sign in to comment.