This commit is contained in:
benbierens 2024-12-06 11:03:56 +01:00
parent 1f063fe163
commit dcf43d3227
No known key found for this signature in database
GPG Key ID: 877D2C2E09A22F3A
1 changed files with 10 additions and 11 deletions

View File

@ -399,7 +399,6 @@ proc wantListHandler*(
peer = peerCtx.id
address = e.address
wantType = $e.wantType
isCancel = $e.cancel
# Update metrics
if e.wantType == WantType.WantHave:
@ -412,18 +411,9 @@ proc wantListHandler*(
if idx < 0: # new entry
if not e.cancel:
peerCtx.peerWants.add(e)
else: # update existing entry
# peer doesn't want this block anymore
if e.cancel:
peerCtx.peerWants.del(idx)
else:
# peer might want to ask for the same cid with
# different want params
peerCtx.peerWants[idx] = e # update entry
if not e.cancel:
# Respond to wantHaves immediately
if e.wantType == WantType.WantHave:
# does this happen for cancels?!
let
have = await e.address in b.localStore
price = @(
@ -443,6 +433,15 @@ proc wantListHandler*(
`type`: BlockPresenceType.Have,
price: price))
else: # update existing entry
# peer doesn't want this block anymore
if e.cancel:
peerCtx.peerWants.del(idx)
else:
# peer might want to ask for the same cid with
# different want params
peerCtx.peerWants[idx] = e # update entry
if presence.len > 0:
trace "Sending presence to remote", items = presence.mapIt($it).join(",")
await b.network.request.sendPresence(peer, presence)