fast
This commit is contained in:
parent
1f063fe163
commit
dcf43d3227
|
@ -399,7 +399,6 @@ proc wantListHandler*(
|
||||||
peer = peerCtx.id
|
peer = peerCtx.id
|
||||||
address = e.address
|
address = e.address
|
||||||
wantType = $e.wantType
|
wantType = $e.wantType
|
||||||
isCancel = $e.cancel
|
|
||||||
|
|
||||||
# Update metrics
|
# Update metrics
|
||||||
if e.wantType == WantType.WantHave:
|
if e.wantType == WantType.WantHave:
|
||||||
|
@ -412,18 +411,9 @@ proc wantListHandler*(
|
||||||
if idx < 0: # new entry
|
if idx < 0: # new entry
|
||||||
if not e.cancel:
|
if not e.cancel:
|
||||||
peerCtx.peerWants.add(e)
|
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:
|
if e.wantType == WantType.WantHave:
|
||||||
|
# does this happen for cancels?!
|
||||||
let
|
let
|
||||||
have = await e.address in b.localStore
|
have = await e.address in b.localStore
|
||||||
price = @(
|
price = @(
|
||||||
|
@ -443,6 +433,15 @@ proc wantListHandler*(
|
||||||
`type`: BlockPresenceType.Have,
|
`type`: BlockPresenceType.Have,
|
||||||
price: price))
|
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:
|
if presence.len > 0:
|
||||||
trace "Sending presence to remote", items = presence.mapIt($it).join(",")
|
trace "Sending presence to remote", items = presence.mapIt($it).join(",")
|
||||||
await b.network.request.sendPresence(peer, presence)
|
await b.network.request.sendPresence(peer, presence)
|
||||||
|
|
Loading…
Reference in New Issue