mirror of
https://github.com/status-im/nim-dagger.git
synced 2025-02-28 22:30:52 +00:00
* fix(statemachine): do not raise from state.run * fix rebase * fix exception handling in SaleProvingSimulated.prove - re-raise CancelledError - don't return State on CatchableError - expect the Proofs_InvalidProof custom error instead of checking a string * asyncSpawn salesagent.onCancelled This was swallowing a KeyError in one of the tests (fixed in the previous commit) * remove error handling states in asyncstatemachine * revert unneeded changes * formatting * PR feedback, logging updates
37 lines
1.0 KiB
Nim
37 lines
1.0 KiB
Nim
import pkg/chronos
|
|
|
|
import ../../logutils
|
|
import ../../utils/exceptions
|
|
import ../statemachine
|
|
import ../salesagent
|
|
import ./errored
|
|
|
|
logScope:
|
|
topics = "marketplace sales ignored"
|
|
|
|
# Ignored slots could mean there was no availability or that the slot could
|
|
# not be reserved.
|
|
|
|
type SaleIgnored* = ref object of SaleState
|
|
reprocessSlot*: bool # readd slot to queue with `seen` flag
|
|
returnBytes*: bool # return unreleased bytes from Reservation to Availability
|
|
|
|
method `$`*(state: SaleIgnored): string =
|
|
"SaleIgnored"
|
|
|
|
method run*(
|
|
state: SaleIgnored, machine: Machine
|
|
): Future[?State] {.async: (raises: []).} =
|
|
let agent = SalesAgent(machine)
|
|
|
|
try:
|
|
if onCleanUp =? agent.onCleanUp:
|
|
await onCleanUp(
|
|
reprocessSlot = state.reprocessSlot, returnBytes = state.returnBytes
|
|
)
|
|
except CancelledError as e:
|
|
trace "SaleIgnored.run was cancelled", error = e.msgDetail
|
|
except CatchableError as e:
|
|
error "Error during SaleIgnored.run in onCleanUp", error = e.msgDetail
|
|
return some State(SaleErrored(error: e))
|