Skip to content

Commit

Permalink
chore: readability improvements
Browse files Browse the repository at this point in the history
  • Loading branch information
danisharora099 committed Oct 9, 2024
1 parent 919aeac commit 1531f15
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions packages/sdk/src/protocols/peer_manager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import { ConnectionManager, getHealthManager } from "@waku/core";
import { BaseProtocol } from "@waku/core/lib/base_protocol";
import { IHealthManager } from "@waku/interfaces";
import { Logger } from "@waku/utils";
import { bytesToUtf8 } from "@waku/utils/bytes";
import { Mutex } from "async-mutex";

const METADATA_KEY = "usedByProtocol";
Expand Down Expand Up @@ -156,10 +157,9 @@ export class PeerManager {

private isPeerUsedByProtocol(peer: Peer): boolean {
const usedByProtocol = peer.metadata.get(METADATA_KEY);
return usedByProtocol
? utf8ToBytes(this.core.multicodec.toString()).every(
(byte, index) => byte === usedByProtocol[index]
)
: false;
if (!usedByProtocol) return false;

const protocolString = bytesToUtf8(usedByProtocol);
return protocolString === this.core.multicodec.toString();
}
}

0 comments on commit 1531f15

Please sign in to comment.