mirror of
https://github.com/logos-storage/logos-storage-nim.git
synced 2026-01-05 23:13:09 +00:00
* openAPI: StorageRequestCreation: reward => pricePerByte, collateral => collateralPerByte * purchasing: reward => pricePerByte, collateral => collateralPerByte * Updates availabilities and reservations to use totalCollateral, minPricePerByte, and maxCollateralPerByte * Uses correct div operator when operating on UInt256 * proposal updating totalCollateral in availability * makes sure that reading currentCollateral happens before freeing slot * Updates naming * fixes tests: unit and contracts * uses feat/price-per-byte branch for codex-contracts-eth * temporarily disables integration tests on CI * introduces high level <<totalCollateral>> property for a cleaner external interface * updates integration tests * Applies review comments * Updates description of totalCollateral in SalesAvailability * updates codex-contracts-eth (price-per-byte)
37 lines
973 B
Nim
37 lines
973 B
Nim
import pkg/chronos
|
|
|
|
import ../../logutils
|
|
import ../statemachine
|
|
import ../salesagent
|
|
import ./errorhandling
|
|
import ./cancelled
|
|
import ./failed
|
|
|
|
logScope:
|
|
topics = "marketplace sales finished"
|
|
|
|
type SaleFinished* = ref object of ErrorHandlingState
|
|
returnedCollateral*: ?UInt256
|
|
|
|
method `$`*(state: SaleFinished): string =
|
|
"SaleFinished"
|
|
|
|
method onCancelled*(state: SaleFinished, request: StorageRequest): ?State =
|
|
return some State(SaleCancelled())
|
|
|
|
method onFailed*(state: SaleFinished, request: StorageRequest): ?State =
|
|
return some State(SaleFailed())
|
|
|
|
method run*(state: SaleFinished, machine: Machine): Future[?State] {.async.} =
|
|
let agent = SalesAgent(machine)
|
|
let data = agent.data
|
|
|
|
without request =? data.request:
|
|
raiseAssert "no sale request"
|
|
|
|
info "Slot finished and paid out",
|
|
requestId = data.requestId, slotIndex = data.slotIndex
|
|
|
|
if onCleanUp =? agent.onCleanUp:
|
|
await onCleanUp(returnedCollateral = state.returnedCollateral)
|