From 3cb8ebdd8fee7d8e404889d2f823c2c95244556f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?rich=CE=9Brd?= Date: Fri, 8 Nov 2024 14:36:16 +0700 Subject: [PATCH] refactor(libwaku): allow several multiaddresses for a single peer in store queries (#3171) * fix: parameter name * refactor: allow multiple addresses for a peer in a store query --- library/libwaku.nim | 4 ++-- .../requests/protocols/store_request.nim | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/library/libwaku.nim b/library/libwaku.nim index a5828f5d8..2feb44302 100644 --- a/library/libwaku.nim +++ b/library/libwaku.nim @@ -710,7 +710,7 @@ proc waku_peer_exchange_request( proc waku_ping_peer( ctx: ptr WakuContext, - peerID: cstring, + peerAddr: cstring, timeoutMs: cuint, callback: WakuCallBack, userData: pointer, @@ -721,7 +721,7 @@ proc waku_ping_peer( .sendRequestToWakuThread( ctx, RequestType.PING, - PingRequest.createShared(peerID, chronos.milliseconds(timeoutMs)), + PingRequest.createShared(peerAddr, chronos.milliseconds(timeoutMs)), ) .handleRes(callback, userData) diff --git a/library/waku_thread/inter_thread_communication/requests/protocols/store_request.nim b/library/waku_thread/inter_thread_communication/requests/protocols/store_request.nim index 52df4688d..ee2b608c3 100644 --- a/library/waku_thread/inter_thread_communication/requests/protocols/store_request.nim +++ b/library/waku_thread/inter_thread_communication/requests/protocols/store_request.nim @@ -1,4 +1,4 @@ -import std/[json, sugar, options] +import std/[json, sugar, strutils, options] import chronos, chronicles, results import ../../../../../waku/factory/waku, @@ -125,7 +125,7 @@ proc process( let storeQueryRequest = JsonStoreQueryRequest.fromJsonNode(jsonContentRes.get()) - let peer = peers.parsePeerInfo($self[].peerAddr).valueOr: + let peer = peers.parsePeerInfo(($self[].peerAddr).split(",")).valueOr: return err("JsonStoreQueryRequest failed to parse peer addr: " & $error) let queryResponse = (await waku.node.wakuStoreClient.query(storeQueryRequest, peer)).valueOr: