adds wants type

This commit is contained in:
benbierens 2023-10-09 11:15:32 +02:00
parent 0da746de7c
commit 1875e6b0d6
No known key found for this signature in database
GPG Key ID: FE44815D96D0A1AA

View File

@ -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,
})