Update documentations and cleanup

This commit is contained in:
Arnaud 2025-02-06 15:17:06 +01:00
parent 9764d3f133
commit ffd149fba8
No known key found for this signature in database
GPG Key ID: 69D6CE281FCAE663
7 changed files with 19 additions and 13 deletions

View File

@ -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

View File

@ -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:

View File

@ -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

View File

@ -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(

View File

@ -150,7 +150,7 @@ asyncchecksuite "Sales":
duration = 60.u256,
minPricePerBytePerSecond = minPricePerBytePerSecond,
totalCollateral = totalCollateral,
enabled = some true,
enabled = true,
until = 0.SecondsSince1970,
)
request = StorageRequest(

View File

@ -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)

View File

@ -85,7 +85,7 @@ multinodesuite "Sales":
totalCollateral = 300.u256,
).get
var until = cast[SecondsSince1970](getTime().toUnix())
var until = getTime().toUnix()
host.patchAvailability(
availability.id,