Skip to content

Commit

Permalink
metadata: store peerIdStr instead of peerId
Browse files Browse the repository at this point in the history
  • Loading branch information
danisharora099 committed Jan 16, 2024
1 parent 62725c1 commit 7475a2c
Showing 1 changed file with 4 additions and 8 deletions.
12 changes: 4 additions & 8 deletions packages/core/src/lib/metadata/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import { IncomingStreamData } from "@libp2p/interface/stream-handler";
import type {
IMetadata,
Libp2pComponents,
PeerIdStr,
ShardInfo,
ShardingParams
} from "@waku/interfaces";
Expand All @@ -21,12 +22,7 @@ export const MetadataCodec = "/vac/waku/metadata/1.0.0";

class Metadata extends BaseProtocol implements IMetadata {
private libp2pComponents: Libp2pComponents;
handshakesConfirmed: Set<PeerId> = new Set();

checkHandshake(peerId: PeerId): boolean {
const handshakesArr = [...this.handshakesConfirmed];
return handshakesArr.some((id) => id.equals(peerId));
}
handshakesConfirmed: Set<PeerIdStr> = new Set();

constructor(
public shardInfo: ShardingParams,
Expand Down Expand Up @@ -98,7 +94,7 @@ class Metadata extends BaseProtocol implements IMetadata {
}

public async confirmOrAttemptHandshake(peerId: PeerId): Promise<void> {
if (this.checkHandshake(peerId)) return;
if (this.handshakesConfirmed.has(peerId.toString())) return;

await this.query(peerId);

Expand Down Expand Up @@ -131,7 +127,7 @@ class Metadata extends BaseProtocol implements IMetadata {
}
});

this.handshakesConfirmed.add(peerId);
this.handshakesConfirmed.add(peerId.toString());
}
}

Expand Down

0 comments on commit 7475a2c

Please sign in to comment.