mirror of
https://github.com/logos-storage/logos-storage-nim.git
synced 2026-01-16 20:33:09 +00:00
uses SafeAsyncIter in "listBlocks" and in "getBlockExpirations"
This commit is contained in:
parent
edf4627dbd
commit
4d5dfb15d0
@ -96,28 +96,18 @@ proc advertiseBlock(b: Advertiser, cid: Cid) {.async: (raises: [CancelledError])
|
||||
proc advertiseLocalStoreLoop(b: Advertiser) {.async: (raises: []).} =
|
||||
try:
|
||||
while b.advertiserRunning:
|
||||
if cidsIter =? await b.localStore.listBlocks(blockType = BlockType.Torrent):
|
||||
trace "Advertiser begins iterating torrent blocks..."
|
||||
for c in cidsIter:
|
||||
if cid =? (await cast[Future[?!Cid].Raising([CancelledError])](c)):
|
||||
await b.advertiseBlock(cid)
|
||||
trace "Advertiser iterating torrent blocks finished."
|
||||
if cidsIter =? await b.localStore.listBlocks(blockType = BlockType.Manifest):
|
||||
trace "Advertiser begins iterating blocks..."
|
||||
for c in cidsIter:
|
||||
if cid =? await c:
|
||||
if cid =? (await cast[Future[?!Cid].Raising([CancelledError])](c)):
|
||||
await b.advertiseBlock(cid)
|
||||
trace "Advertiser iterating blocks finished."
|
||||
try:
|
||||
if cids =? await b.localStore.listBlocks(blockType = BlockType.Torrent):
|
||||
trace "Advertiser begins iterating torrent blocks..."
|
||||
for c in cids:
|
||||
if cid =? await c:
|
||||
await b.advertiseBlock(cid)
|
||||
trace "Advertiser iterating torrent blocks finished."
|
||||
if cids =? await b.localStore.listBlocks(blockType = BlockType.Manifest):
|
||||
trace "Advertiser begins iterating blocks..."
|
||||
for c in cids:
|
||||
if cid =? await c:
|
||||
await b.advertiseBlock(cid)
|
||||
trace "Advertiser iterating blocks finished."
|
||||
except CatchableError as e:
|
||||
error "Error in advertise local store loop", error = e.msgDetail
|
||||
raiseAssert("Unexpected exception in advertiseLocalStoreLoop")
|
||||
|
||||
await sleepAsync(b.advertiseLocalStoreLoopSleep)
|
||||
except CancelledError:
|
||||
|
||||
@ -296,7 +296,9 @@ asyncchecksuite "RepoStore":
|
||||
beIter: Future[?!SafeAsyncIter[BlockExpiration]]
|
||||
): Future[seq[BlockExpiration]] {.async: (raises: [CatchableError]).} =
|
||||
var expirations = newSeq[BlockExpiration](0)
|
||||
without iter =? (await beIter), err:
|
||||
without iter =? (
|
||||
await cast[Future[?!SafeAsyncIter[BlockExpiration]].Raising([CancelledError])](beIter)
|
||||
), err:
|
||||
return expirations
|
||||
for beFut in toSeq(iter):
|
||||
if value =? (await beFut):
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user