From 1875e6b0d6a949b3990aa628ed597506648ee5df Mon Sep 17 00:00:00 2001 From: benbierens Date: Mon, 9 Oct 2023 11:15:32 +0200 Subject: [PATCH] adds wants type --- codex/rest/api.nim | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/codex/rest/api.nim b/codex/rest/api.nim index 3d2c680e..08cd97d9 100644 --- a/codex/rest/api.nim +++ b/codex/rest/api.nim @@ -22,9 +22,9 @@ import pkg/presto import pkg/libp2p import pkg/metrics import pkg/stew/base10 +import pkg/stew/base58 import pkg/stew/byteutils import pkg/confutils - import pkg/libp2p import pkg/libp2p/routing_record import pkg/codexdht/discv5/spr as spr @@ -104,10 +104,20 @@ proc formatBlockExchangePeers(peers: OrderedTable[PeerId, BlockExcPeerCtx]): Jso "price": $presence.price }) + let jwantsArray = newJArray() + for want in peerContext.peerWants: + jwantsArray.add(%*{ + "block": base58.encode(Base58, want.`block`), + "priority": $want.priority, + "cancel": $want.cancel, + "wantType": $want.wantType, + "sendDontHave": $want.sendDontHave + }) + jarray.add(%*{ "peerid": $peerId, "hasBlocks": jblocksArray, - "wants": $peerContext.peerWants.len, + "wants": jwantsArray, "exchanged": $peerContext.exchanged, })