Fixes issue where peerWants are only stored for type wantBlock.

This commit is contained in:
Ben 2024-12-04 14:58:58 +01:00
parent 7c2bff79c0
commit 64e691b824
No known key found for this signature in database
GPG Key ID: 0F16E812E736C24B

View File

@ -399,7 +399,9 @@ proc wantListHandler*(
address = e.address address = e.address
wantType = $e.wantType wantType = $e.wantType
if idx < 0: # updating entry if idx < 0: # new entry
peerCtx.peerWants.add(e)
let let
have = await e.address in b.localStore have = await e.address in b.localStore
price = @( price = @(
@ -408,6 +410,8 @@ proc wantListHandler*(
if e.wantType == WantType.WantHave: if e.wantType == WantType.WantHave:
codex_block_exchange_want_have_lists_received.inc() 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: if not have and e.sendDontHave:
presence.add( presence.add(
@ -421,10 +425,8 @@ proc wantListHandler*(
address: e.address, address: e.address,
`type`: BlockPresenceType.Have, `type`: BlockPresenceType.Have,
price: price)) price: price))
elif e.wantType == WantType.WantBlock:
peerCtx.peerWants.add(e) else: # update existing entry
codex_block_exchange_want_block_lists_received.inc()
else:
# peer doesn't want this block anymore # peer doesn't want this block anymore
if e.cancel: if e.cancel:
peerCtx.peerWants.del(idx) peerCtx.peerWants.del(idx)