mirror of
https://github.com/logos-storage/logos-storage-nim.git
synced 2026-01-04 06:23:06 +00:00
use a case-of instead of if for better readability (#1063)
This commit is contained in:
parent
e62a09d9b1
commit
17d3f99f45
@ -398,7 +398,8 @@ proc wantListHandler*(b: BlockExcEngine, peer: PeerId, wantList: WantList) {.asy
|
|||||||
have = await e.address in b.localStore
|
have = await e.address in b.localStore
|
||||||
price = @(b.pricing.get(Pricing(price: 0.u256)).price.toBytesBE)
|
price = @(b.pricing.get(Pricing(price: 0.u256)).price.toBytesBE)
|
||||||
|
|
||||||
if e.wantType == WantType.WantHave:
|
case e.wantType:
|
||||||
|
of WantType.WantHave:
|
||||||
if have:
|
if have:
|
||||||
presence.add(
|
presence.add(
|
||||||
BlockPresence(
|
BlockPresence(
|
||||||
@ -415,17 +416,19 @@ proc wantListHandler*(b: BlockExcEngine, peer: PeerId, wantList: WantList) {.asy
|
|||||||
peerCtx.peerWants.add(e)
|
peerCtx.peerWants.add(e)
|
||||||
|
|
||||||
codex_block_exchange_want_have_lists_received.inc()
|
codex_block_exchange_want_have_lists_received.inc()
|
||||||
elif e.wantType == WantType.WantBlock:
|
of WantType.WantBlock:
|
||||||
peerCtx.peerWants.add(e)
|
peerCtx.peerWants.add(e)
|
||||||
schedulePeer = true
|
schedulePeer = true
|
||||||
codex_block_exchange_want_block_lists_received.inc()
|
codex_block_exchange_want_block_lists_received.inc()
|
||||||
else: # Updating existing entry in peer wants
|
else: # Updating existing entry in peer wants
|
||||||
# peer doesn't want this block anymore
|
# peer doesn't want this block anymore
|
||||||
if e.cancel:
|
if e.cancel:
|
||||||
|
trace "Canceling want for block", address = e.address
|
||||||
peerCtx.peerWants.del(idx)
|
peerCtx.peerWants.del(idx)
|
||||||
else:
|
else:
|
||||||
# peer might want to ask for the same cid with
|
# peer might want to ask for the same cid with
|
||||||
# different want params
|
# different want params
|
||||||
|
trace "Updating want for block", address = e.address
|
||||||
peerCtx.peerWants[idx] = e # update entry
|
peerCtx.peerWants[idx] = e # update entry
|
||||||
|
|
||||||
if presence.len > 0:
|
if presence.len > 0:
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user