From 09abb7ce49a43d82a25d546aa6d70824b4361b11 Mon Sep 17 00:00:00 2001 From: Dmitriy Ryajov Date: Wed, 20 Apr 2022 12:11:59 -0600 Subject: [PATCH] - don't send want reqs to peers reporting the cid - Don't request blocks directly on presense update, use `requestBlock` --- dagger/blockexchange/engine.nim | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/dagger/blockexchange/engine.nim b/dagger/blockexchange/engine.nim index 4a86c63a..d70d2725 100644 --- a/dagger/blockexchange/engine.nim +++ b/dagger/blockexchange/engine.nim @@ -245,6 +245,7 @@ proc requestBlock*( # get the first peer with at least one (any) # matching cid + # TODO: this should be sorted by best to worst var blockPeer: BlockExcPeerCtx for p in peers: if cid in p.peerHave: @@ -252,12 +253,11 @@ proc requestBlock*( break # didn't find any peer with matching cids - # use the first one in the sorted array if isNil(blockPeer): blockPeer = peers[0] peers.keepItIf( - it != blockPeer + it != blockPeer and cid notin it.peerHave ) # request block @@ -306,10 +306,8 @@ proc blockPresenceHandler*( ) if cids.len > 0: - b.network.request.sendWantList( - peerCtx.id, - cids, - wantType = WantType.wantBlock) # we want this remote to send us a block + for cid in cids: + asyncCheck b.requestBlock(cid) proc scheduleTasks(b: BlockExcEngine, blocks: seq[bt.Block]) = trace "Schedule a task for new blocks"