mirror of
https://github.com/logos-storage/logos-storage-nim.git
synced 2026-01-03 14:03:10 +00:00
* checked exceptions in stores
* makes asynciter as much exception safe as it gets
* introduce "SafeAsyncIter" that uses Results and limits exceptions to cancellations
* adds {.push raises: [].} to errors
* uses SafeAsyncIter in "listBlocks" and in "getBlockExpirations"
* simplifies safeasynciter (magic of auto)
* gets rid of ugly casts
* tiny fix in hte way we create raising futures in tests of safeasynciter
* Removes two more casts caused by using checked exceptions
* adds an extended explanation of one more complex SafeAsyncIter test
* adds missing "finishOnErr" param in slice constructor of SafeAsyncIter
* better fix for "Error: Exception can raise an unlisted exception: Exception" error.
---------
Co-authored-by: Dmitriy Ryajov <dryajov@gmail.com>
41 lines
1.3 KiB
Nim
41 lines
1.3 KiB
Nim
import pkg/questionable
|
|
import pkg/questionable/results
|
|
import pkg/upraises
|
|
import pkg/libp2p/cid
|
|
|
|
import ../market
|
|
import ../clock
|
|
import ./slotqueue
|
|
import ./reservations
|
|
import ../blocktype as bt
|
|
|
|
type
|
|
SalesContext* = ref object
|
|
market*: Market
|
|
clock*: Clock
|
|
# Sales-level callbacks. Closure will be overwritten each time a slot is
|
|
# processed.
|
|
onStore*: ?OnStore
|
|
onClear*: ?OnClear
|
|
onSale*: ?OnSale
|
|
onProve*: ?OnProve
|
|
onExpiryUpdate*: ?OnExpiryUpdate
|
|
reservations*: Reservations
|
|
slotQueue*: SlotQueue
|
|
simulateProofFailures*: int
|
|
|
|
BlocksCb* = proc(blocks: seq[bt.Block]): Future[?!void] {.
|
|
gcsafe, async: (raises: [CancelledError])
|
|
.}
|
|
OnStore* = proc(
|
|
request: StorageRequest, slot: uint64, blocksCb: BlocksCb, isRepairing: bool
|
|
): Future[?!void] {.gcsafe, async: (raises: [CancelledError]).}
|
|
OnProve* = proc(slot: Slot, challenge: ProofChallenge): Future[?!Groth16Proof] {.
|
|
gcsafe, async: (raises: [CancelledError])
|
|
.}
|
|
OnExpiryUpdate* = proc(rootCid: Cid, expiry: SecondsSince1970): Future[?!void] {.
|
|
gcsafe, async: (raises: [CancelledError])
|
|
.}
|
|
OnClear* = proc(request: StorageRequest, slotIndex: uint64) {.gcsafe, raises: [].}
|
|
OnSale* = proc(request: StorageRequest, slotIndex: uint64) {.gcsafe, raises: [].}
|