From 64e691b824bb296c1c8dc34a9269991a1c909953 Mon Sep 17 00:00:00 2001 From: Ben Date: Wed, 4 Dec 2024 14:58:58 +0100 Subject: [PATCH] Fixes issue where peerWants are only stored for type wantBlock. --- codex/blockexchange/engine/engine.nim | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/codex/blockexchange/engine/engine.nim b/codex/blockexchange/engine/engine.nim index b4ed734b..16b2169b 100644 --- a/codex/blockexchange/engine/engine.nim +++ b/codex/blockexchange/engine/engine.nim @@ -399,7 +399,9 @@ proc wantListHandler*( address = e.address wantType = $e.wantType - if idx < 0: # updating entry + if idx < 0: # new entry + peerCtx.peerWants.add(e) + let have = await e.address in b.localStore price = @( @@ -408,6 +410,8 @@ proc wantListHandler*( if e.wantType == WantType.WantHave: codex_block_exchange_want_have_lists_received.inc() + elif e.wantType == WantType.WantBlock: + codex_block_exchange_want_block_lists_received.inc() if not have and e.sendDontHave: presence.add( @@ -421,10 +425,8 @@ proc wantListHandler*( address: e.address, `type`: BlockPresenceType.Have, price: price)) - elif e.wantType == WantType.WantBlock: - peerCtx.peerWants.add(e) - codex_block_exchange_want_block_lists_received.inc() - else: + + else: # update existing entry # peer doesn't want this block anymore if e.cancel: peerCtx.peerWants.del(idx)