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

BlockExchange improvement 1 #964

Closed
wants to merge 2 commits into from
Closed
Changes from 1 commit
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
Prev Previous commit
Fixes issue where only wants of type block are stored in peerContext
benbierens committed Oct 22, 2024

Verified

This commit was signed with the committer’s verified signature.
benbierens Ben Bierens
commit 2a254601d97825f686a2d6f4f435ca7871425509
6 changes: 3 additions & 3 deletions codex/blockexchange/engine/engine.nim
Original file line number Diff line number Diff line change
@@ -187,13 +187,13 @@
if not b.pendingBlocks.isInFlight(address):
let peers = b.peers.selectCheapest(address)
if peers.len > 0:
let peer = peers[hash(address) mod peers.len]

Check warning on line 190 in codex/blockexchange/engine/engine.nim

Codecov / codecov/patch

codex/blockexchange/engine/engine.nim#L190

Added line #L190 was not covered by tests
trace "Existing peers found for address.", address, nPeers = peers.len, selectedPeer = peer.id
asyncSpawn b.monitorBlockHandle(blockFuture, address, peer.id)
b.pendingBlocks.setInFlight(address)
await b.sendWantBlock(address, peer)
await b.sendWantHave(address, @[peer], toSeq(b.peers))
else:

Check warning on line 196 in codex/blockexchange/engine/engine.nim

Codecov / codecov/patch

codex/blockexchange/engine/engine.nim#L196

Added line #L196 was not covered by tests
trace "No existing peers found for address.", address
b.discovery.queueFindBlocksReq(@[address.cidOrTreeCid])
await b.sendWantHave(address, @[], toSeq(b.peers))
@@ -401,7 +401,8 @@
address = e.address
wantType = $e.wantType

if idx < 0: # updating entry
if idx < 0: # new entry
peerCtx.peerWants.add(e)
let
have = await e.address in b.localStore
price = @(
@@ -424,9 +425,8 @@
`type`: BlockPresenceType.Have,
price: price))
elif e.wantType == WantType.WantBlock:
peerCtx.peerWants.add(e)
codex_block_exchange_want_block_lists_received.inc()
else:
else: # update existing entry
# peer doesn't want this block anymore
if e.cancel:
peerCtx.peerWants.del(idx)