From d782dd5c09fc10e620a25a69b08aa3fd4904fe6e Mon Sep 17 00:00:00 2001 From: alexcos20 Date: Wed, 8 Jan 2025 11:17:31 +0200 Subject: [PATCH] fix comments --- src/components/P2P/index.ts | 2 +- src/components/httpRoutes/getOceanPeers.ts | 3 ++- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/src/components/P2P/index.ts b/src/components/P2P/index.ts index b56906f8b..68062ac6b 100644 --- a/src/components/P2P/index.ts +++ b/src/components/P2P/index.ts @@ -591,8 +591,8 @@ export class OceanP2P extends EventEmitter { } async findPeerInDht(peerName: string, timeout?: number) { - const peer = peerIdFromString(peerName) try { + const peer = peerIdFromString(peerName) const data = await this._libp2p.peerRouting.findPeer(peer, { signal: isNaN(timeout) || timeout === 0 diff --git a/src/components/httpRoutes/getOceanPeers.ts b/src/components/httpRoutes/getOceanPeers.ts index 0cf4e25d0..5ed5caa05 100644 --- a/src/components/httpRoutes/getOceanPeers.ts +++ b/src/components/httpRoutes/getOceanPeers.ts @@ -31,7 +31,8 @@ getOceanPeersRoute.get( const peers = await req.oceanNode .getP2PNode() .findPeerInDht(String(req.query.peerId), parseInt(String(req.query.timeout))) - res.json(peers) + if (peers) res.json(peers) + else res.sendStatus(404).send('Cannot find peer') } else { sendMissingP2PResponse(res) }