mirror of
https://github.com/logos-storage/logos-storage-nim.git
synced 2026-01-02 13:33:10 +00:00
* Indicate that slot is being repaired when trying to download * Fix tests * Apply nph * Calculate the repair collateral when adding the item into the queue * Add slotCollateral calculation with getRequest cache and remove populationItem function * Update with pricePerByte * Simplify StorageAsk parameter * Minor fixes * Move cache request to another PR * Rename SlotQueueItem collateral and required in init * Use override func to optimise calls when the slot state is known * Remove unused code * Cosmetic change * Use raiseMarketError helper * Add exceptions to async pragma * Cosmetic change * Use raiseMarketError helper * Let slotCollateral determines the slot sate * Use configSync to avoid async pragma in onStorageRequested * Add loadConfig function * Add CatchableError to async pragma * Add missing pragma raises errors * Move loadConfig * Avoid swallow CancelledError * Avoid swallowing CancelledError * Avoid swallowing CancelledError * Update error messages * Except MarketError instead of CatchableError * Fix merge issue * Log fatal when configuration cannot be loaded * Propagate MarketError in slotCollateral * Remove useless configSync * Use result with explicit error * Fix syntax --------- Signed-off-by: Arnaud <arnaud@status.im>
39 lines
1.2 KiB
Nim
39 lines
1.2 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, raises: [].}
|
|
OnStore* = proc(
|
|
request: StorageRequest, slot: uint64, blocksCb: BlocksCb, isRepairing: bool
|
|
): Future[?!void] {.gcsafe, upraises: [].}
|
|
OnProve* = proc(slot: Slot, challenge: ProofChallenge): Future[?!Groth16Proof] {.
|
|
gcsafe, upraises: []
|
|
.}
|
|
OnExpiryUpdate* = proc(rootCid: Cid, expiry: SecondsSince1970): Future[?!void] {.
|
|
gcsafe, upraises: []
|
|
.}
|
|
OnClear* = proc(request: StorageRequest, slotIndex: uint64) {.gcsafe, upraises: [].}
|
|
OnSale* = proc(request: StorageRequest, slotIndex: uint64) {.gcsafe, upraises: [].}
|