mirror of
https://github.com/logos-storage/logos-storage-nim.git
synced 2026-01-03 14:03:10 +00:00
* extra utilities and tweaks * add atlas lock * update ignores * break build into it's own script * update url rules * base off codexdht's * compile fixes for Nim 1.6.14 * update submodules * convert mapFailure to procs to work around type resolution issues * add toml parser for multiaddress * change error type on keyutils * bump nimbus build to use 1.6.14 * update gitignore * adding new deps submodules * bump nim ci version * even more fixes * more libp2p changes * update keys * fix eventually function * adding coverage test file * move coverage to build.nims * use nimcache/coverage * move libp2p import for tests into helper.nim * remove named bin * bug fixes for networkpeers (from Dmitriy) --------- Co-authored-by: Dmitriy Ryajov <dryajov@gmail.com>
26 lines
664 B
Nim
26 lines
664 B
Nim
import pkg/chronos
|
|
|
|
template eventuallyCheck*(condition: untyped, timeout = 5.seconds): bool =
|
|
proc loop: Future[bool] {.async.} =
|
|
let start = Moment.now()
|
|
while true:
|
|
if condition:
|
|
return true
|
|
if Moment.now() > (start + timeout):
|
|
return false
|
|
else:
|
|
await sleepAsync(1.millis)
|
|
await loop()
|
|
|
|
template always*(condition: untyped, timeout = 50.millis): bool =
|
|
proc loop: Future[bool] {.async.} =
|
|
let start = Moment.now()
|
|
while true:
|
|
if not condition:
|
|
return false
|
|
if Moment.now() > (start + timeout):
|
|
return true
|
|
else:
|
|
await sleepAsync(1.millis)
|
|
await loop()
|