Skip to content

Commit

Permalink
chore: handle edge case
Browse files Browse the repository at this point in the history
  • Loading branch information
danisharora099 committed Aug 28, 2024
1 parent 2b61774 commit f387f59
Showing 1 changed file with 8 additions and 3 deletions.
11 changes: 8 additions & 3 deletions packages/sdk/src/protocols/filter/reliability_monitor.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,7 @@ import { Logger } from "@waku/utils";

type ReceivedMessageHashes = {
all: Set<string>;
nodes: {
[peerId: PeerIdStr]: Set<string>;
};
nodes: Record<PeerIdStr, Set<string>>;
};

const DEFAULT_MAX_MISSED_MESSAGES_THRESHOLD = 3;
Expand Down Expand Up @@ -60,6 +58,13 @@ export class ReliabilityMonitor {
this.receivedMessagesHashes.all.add(hashedMessageStr);

if (peerIdStr) {
const x = this.receivedMessagesHashes.nodes[peerIdStr];
if (!x) {
log.warn(
`Peer ${peerIdStr} not initialized in receivedMessagesHashes.nodes, adding it.`
);
this.receivedMessagesHashes.nodes[peerIdStr] = new Set();
}
this.receivedMessagesHashes.nodes[peerIdStr].add(hashedMessageStr);
}

Expand Down

0 comments on commit f387f59

Please sign in to comment.