Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

use a case-of instead of if for better readability #1063

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 5 additions & 2 deletions codex/blockexchange/engine/engine.nim
Original file line number Diff line number Diff line change
Expand Up @@ -408,7 +408,8 @@ proc wantListHandler*(
b.pricing.get(Pricing(price: 0.u256))
.price.toBytesBE)

if e.wantType == WantType.WantHave:
case e.wantType:
of WantType.WantHave:
if have:
presence.add(
BlockPresence(
Expand All @@ -425,17 +426,19 @@ proc wantListHandler*(
peerCtx.peerWants.add(e)

codex_block_exchange_want_have_lists_received.inc()
elif e.wantType == WantType.WantBlock:
of WantType.WantBlock:
peerCtx.peerWants.add(e)
schedulePeer = true
codex_block_exchange_want_block_lists_received.inc()
else: # Updating existing entry in peer wants
# peer doesn't want this block anymore
if e.cancel:
trace "Canceling want for block", address = e.address
peerCtx.peerWants.del(idx)
else:
# peer might want to ask for the same cid with
# different want params
trace "Updating want for block", address = e.address
peerCtx.peerWants[idx] = e # update entry

if presence.len > 0:
Expand Down
Loading