diff --git a/codex/sales/reservations.nim b/codex/sales/reservations.nim index 2bfb6a66..cd272924 100644 --- a/codex/sales/reservations.nim +++ b/codex/sales/reservations.nim @@ -71,11 +71,11 @@ type minPricePerBytePerSecond* {.serialize.}: UInt256 totalCollateral {.serialize.}: UInt256 totalRemainingCollateral* {.serialize.}: UInt256 - # If false, the availability will not be able to receive new slots. - # If it is turned on and the availability is already hosting slots, - # it will not affect those existing slots. + # If set to false, the availability will not accept new slots. + # If enabled, it will not impact any existing slots that are already being hosted. enabled* {.serialize.}: bool - # 0 means non-restricted, otherwise contains timestamp until the Availability will be renewed + # Specifies the latest date after which sales will no longer be accepted for availability. + # If set to 0, there will be no restrictions. until* {.serialize.}: SecondsSince1970 Reservation* = ref object @@ -661,7 +661,8 @@ proc findAvailability*( pricePerBytePerSecond, availMinPricePerBytePerSecond = availability.minPricePerBytePerSecond, collateralPerByte, - availMaxCollateralPerByte = availability.maxCollateralPerByte + availMaxCollateralPerByte = availability.maxCollateralPerByte, + until = availability.until # TODO: As soon as we're on ARC-ORC, we can use destructors # to automatically dispose our iterators when they fall out of scope. @@ -681,4 +682,5 @@ proc findAvailability*( pricePerBytePerSecond, availMinPricePerBytePerSecond = availability.minPricePerBytePerSecond, collateralPerByte, - availMaxCollateralPerByte = availability.maxCollateralPerByte + availMaxCollateralPerByte = availability.maxCollateralPerByte, + until = availability.until diff --git a/openapi.yaml b/openapi.yaml index 3b224c4d..e35a28e8 100644 --- a/openapi.yaml +++ b/openapi.yaml @@ -167,6 +167,10 @@ components: type: boolean description: Enable the ability to receive sales on this availability. default: true + until: + type: integer + description: Specifies the latest date after which sales will no longer be accepted for availability. If set to 0, there will be no restrictions. + default: 0 SalesAvailabilityREAD: allOf: diff --git a/tests/codex/sales/states/testpreparing.nim b/tests/codex/sales/states/testpreparing.nim index 166e41ff..99723a30 100644 --- a/tests/codex/sales/states/testpreparing.nim +++ b/tests/codex/sales/states/testpreparing.nim @@ -39,7 +39,7 @@ asyncchecksuite "sales state 'preparing'": duration = request.ask.duration + 60.u256, minPricePerBytePerSecond = request.ask.pricePerBytePerSecond, totalCollateral = request.ask.collateralPerSlot * request.ask.slots.u256, - enabled = some true, + enabled = true, until = 0.SecondsSince1970, ) let repoDs = SQLiteDatastore.new(Memory).tryGet() @@ -87,7 +87,7 @@ asyncchecksuite "sales state 'preparing'": check ignored.reprocessSlot check ignored.returnBytes == false - test "run switches to ignored when a availability is not enabled": + test "run switches to ignored when availability is not enabled": await createAvailability(enabled = false) let next = !(await state.run(agent)) check next of SaleIgnored diff --git a/tests/codex/sales/testreservations.nim b/tests/codex/sales/testreservations.nim index 1536e461..0dee52ae 100644 --- a/tests/codex/sales/testreservations.nim +++ b/tests/codex/sales/testreservations.nim @@ -274,7 +274,7 @@ asyncchecksuite "Reservations module": check availability.until == 0.SecondsSince1970 test "create availability whith correct values": - var until = cast[SecondsSince1970](getTime().toUnix()) + var until = getTime().toUnix() let availability = createAvailability(enabled = false, until = until) check availability.enabled == false @@ -339,7 +339,7 @@ asyncchecksuite "Reservations module": check not called - test "onAvailabilityAdded is not called when enabled is false": + test "onAvailabilityAdded is not called when availability is disabled": var availability = createAvailability(enabled = false) var called = false reservations.onAvailabilityAdded = proc( diff --git a/tests/codex/sales/testsales.nim b/tests/codex/sales/testsales.nim index d4b3b6dd..1b457f6d 100644 --- a/tests/codex/sales/testsales.nim +++ b/tests/codex/sales/testsales.nim @@ -150,7 +150,7 @@ asyncchecksuite "Sales": duration = 60.u256, minPricePerBytePerSecond = minPricePerBytePerSecond, totalCollateral = totalCollateral, - enabled = some true, + enabled = true, until = 0.SecondsSince1970, ) request = StorageRequest( diff --git a/tests/integration/codexclient.nim b/tests/integration/codexclient.nim index 10b1dbcf..5d642adf 100644 --- a/tests/integration/codexclient.nim +++ b/tests/integration/codexclient.nim @@ -187,7 +187,7 @@ proc postAvailabilityRaw*( "duration": duration, "minPricePerBytePerSecond": minPricePerBytePerSecond, "totalCollateral": totalCollateral, - "enabled": enabled |? true, + "enabled": enabled, "until": until, } return client.http.post(url, $json) diff --git a/tests/integration/testsales.nim b/tests/integration/testsales.nim index dbe1ccb0..937c6365 100644 --- a/tests/integration/testsales.nim +++ b/tests/integration/testsales.nim @@ -85,7 +85,7 @@ multinodesuite "Sales": totalCollateral = 300.u256, ).get - var until = cast[SecondsSince1970](getTime().toUnix()) + var until = getTime().toUnix() host.patchAvailability( availability.id,