2023-07-20 07:56:28 +00:00
|
|
|
import pkg/metrics
|
2022-09-27 14:27:40 +00:00
|
|
|
import ../statemachine
|
2023-06-05 08:48:06 +00:00
|
|
|
import ./errorhandling
|
2022-09-27 14:27:40 +00:00
|
|
|
import ./submitted
|
|
|
|
|
2023-11-03 15:21:54 +00:00
|
|
|
declareCounter(codex_purchases_pending, "codex purchases pending")
|
2023-07-20 07:56:28 +00:00
|
|
|
|
2023-06-05 08:48:06 +00:00
|
|
|
type PurchasePending* = ref object of ErrorHandlingState
|
2022-09-27 14:27:40 +00:00
|
|
|
|
2023-06-05 08:48:06 +00:00
|
|
|
method `$`*(state: PurchasePending): string =
|
2022-11-08 07:10:17 +00:00
|
|
|
"pending"
|
2023-06-05 08:48:06 +00:00
|
|
|
|
|
|
|
method run*(state: PurchasePending, machine: Machine): Future[?State] {.async.} =
|
2023-11-03 15:21:54 +00:00
|
|
|
codex_purchases_pending.inc()
|
2023-06-05 08:48:06 +00:00
|
|
|
let purchase = Purchase(machine)
|
|
|
|
let request = !purchase.request
|
|
|
|
await purchase.market.requestStorage(request)
|
|
|
|
return some State(PurchaseSubmitted())
|