Requesting the same CID sometimes causes a worker to discard the request if it's already inflight by another worker. (#1002)

This commit is contained in:
Ben Bierens 2024-11-27 08:13:34 +01:00 committed by GitHub
parent d47ce38894
commit 21249968d4
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
1 changed files with 8 additions and 3 deletions

View File

@ -111,10 +111,11 @@ asyncchecksuite "Test Discovery Engine":
minPeersPerBlock = minPeers) minPeersPerBlock = minPeers)
want = newAsyncEvent() want = newAsyncEvent()
var pendingCids = newSeq[Cid]()
blockDiscovery.findBlockProvidersHandler = blockDiscovery.findBlockProvidersHandler =
proc(d: MockDiscovery, cid: Cid): Future[seq[SignedPeerRecord]] {.async, gcsafe.} = proc(d: MockDiscovery, cid: Cid): Future[seq[SignedPeerRecord]] {.async, gcsafe.} =
check cid in pendingCids
check cid == blocks[0].cid pendingCids.keepItIf(it != cid)
check peerStore.len < minPeers check peerStore.len < minPeers
var var
peerCtx = BlockExcPeerCtx(id: PeerId.example) peerCtx = BlockExcPeerCtx(id: PeerId.example)
@ -126,8 +127,12 @@ asyncchecksuite "Test Discovery Engine":
want.fire() want.fire()
await discoveryEngine.start() await discoveryEngine.start()
var idx = 0
while peerStore.len < minPeers: while peerStore.len < minPeers:
discoveryEngine.queueFindBlocksReq(@[blocks[0].cid]) let cid = blocks[idx].cid
inc idx
pendingCids.add(cid)
discoveryEngine.queueFindBlocksReq(@[cid])
await want.wait() await want.wait()
want.clear() want.clear()