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 86c704b
Show file tree
Hide file tree
Showing 2 changed files with 38 additions and 5 deletions.
33 changes: 33 additions & 0 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

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 86c704b

Please sign in to comment.