From 3f8812f7a50acf79cfafcd4cb160b66eb09e28d7 Mon Sep 17 00:00:00 2001 From: Dmitriy Ryajov Date: Fri, 10 Jan 2025 12:02:51 -0600 Subject: [PATCH] use a case-of instead of if for better readability --- codex/blockexchange/engine/engine.nim | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/codex/blockexchange/engine/engine.nim b/codex/blockexchange/engine/engine.nim index c79e1eab..4c1828d8 100644 --- a/codex/blockexchange/engine/engine.nim +++ b/codex/blockexchange/engine/engine.nim @@ -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( @@ -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: