2023-08-21 10:26:43 +00:00
|
|
|
import pkg/chronicles
|
|
|
|
import ../statemachine
|
|
|
|
import ../salesagent
|
|
|
|
import ./errorhandling
|
|
|
|
import ./filling
|
|
|
|
import ./cancelled
|
|
|
|
import ./failed
|
|
|
|
|
|
|
|
logScope:
|
2023-10-19 08:12:49 +00:00
|
|
|
topics = "marketplace sales initial-proving"
|
2023-08-21 10:26:43 +00:00
|
|
|
|
|
|
|
type
|
|
|
|
SaleInitialProving* = ref object of ErrorHandlingState
|
|
|
|
|
|
|
|
method `$`*(state: SaleInitialProving): string = "SaleInitialProving"
|
|
|
|
|
|
|
|
method onCancelled*(state: SaleInitialProving, request: StorageRequest): ?State =
|
|
|
|
return some State(SaleCancelled())
|
|
|
|
|
|
|
|
method onFailed*(state: SaleInitialProving, request: StorageRequest): ?State =
|
|
|
|
return some State(SaleFailed())
|
|
|
|
|
|
|
|
method run*(state: SaleInitialProving, machine: Machine): Future[?State] {.async.} =
|
|
|
|
let data = SalesAgent(machine).data
|
|
|
|
let context = SalesAgent(machine).context
|
|
|
|
|
|
|
|
without request =? data.request:
|
|
|
|
raiseAssert "no sale request"
|
|
|
|
|
|
|
|
without onProve =? context.onProve:
|
|
|
|
raiseAssert "onProve callback not set"
|
|
|
|
|
|
|
|
debug "Generating initial proof", requestId = $data.requestId
|
2023-11-17 12:49:45 +00:00
|
|
|
let proof = await onProve(Slot(request: request, slotIndex: data.slotIndex))
|
2023-08-21 10:26:43 +00:00
|
|
|
debug "Finished proof calculation", requestId = $data.requestId
|
|
|
|
|
|
|
|
return some State(SaleFilling(proof: proof))
|