mirror of
https://github.com/logos-storage/logos-storage-nim.git
synced 2026-01-03 22:13:12 +00:00
- don't send want reqs to peers reporting the cid
- Don't request blocks directly on presense update, use `requestBlock`
This commit is contained in:
parent
3e40b46474
commit
09abb7ce49
@ -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"
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user