mirror of
https://github.com/codex-storage/nim-codex.git
synced 2025-01-20 17:58:53 +00:00
14c5270e83
* Adds metrics to block exchange. * Adds metrics to purchasing * Adds metrics to upload and download API * Adds metrics to the repo store * Fixes exception in repostore start. * Merge managed to mess up indentation.
19 lines
538 B
Nim
19 lines
538 B
Nim
import pkg/metrics
|
|
import ../statemachine
|
|
import ./errorhandling
|
|
import ./submitted
|
|
|
|
declareCounter(codexPurchasesPending, "codex purchases pending")
|
|
|
|
type PurchasePending* = ref object of ErrorHandlingState
|
|
|
|
method `$`*(state: PurchasePending): string =
|
|
"pending"
|
|
|
|
method run*(state: PurchasePending, machine: Machine): Future[?State] {.async.} =
|
|
codexPurchasesPending.inc()
|
|
let purchase = Purchase(machine)
|
|
let request = !purchase.request
|
|
await purchase.market.requestStorage(request)
|
|
return some State(PurchaseSubmitted())
|