mirror of
https://github.com/codex-storage/nim-codex.git
synced 2025-01-19 01:12:34 +00:00
3181361658
* [state machine] Allow querying of state properties * [purchasing] use new state machine * [state machine] remove old state machine implementation * [purchasing] remove duplication in error handling
16 lines
438 B
Nim
16 lines
438 B
Nim
import ../statemachine
|
|
import ./errorhandling
|
|
import ./submitted
|
|
import ./error
|
|
|
|
type PurchasePending* = ref object of ErrorHandlingState
|
|
|
|
method `$`*(state: PurchasePending): string =
|
|
"pending"
|
|
|
|
method run*(state: PurchasePending, machine: Machine): Future[?State] {.async.} =
|
|
let purchase = Purchase(machine)
|
|
let request = !purchase.request
|
|
await purchase.market.requestStorage(request)
|
|
return some State(PurchaseSubmitted())
|