[sales] make slotIndex non-optional

This commit is contained in:
Mark Spanbroek 2023-02-01 16:49:13 +01:00 committed by Eric Mastro
parent feae3960b7
commit 313c23177b
No known key found for this signature in database
GPG Key ID: 141E3048D95A4E63
4 changed files with 9 additions and 9 deletions

View File

@ -75,8 +75,8 @@ proc handleRequest(sales: Sales,
let agent = newSalesAgent(
sales,
requestId,
slotIndex,
availability,
some slotIndex,
none StorageRequest
)
@ -103,8 +103,8 @@ proc load*(sales: Sales) {.async.} =
let agent = newSalesAgent(
sales,
request.id,
slotIndex,
availability,
some slotIndex,
some request)
await agent.start(request.ask.slots)

View File

@ -6,8 +6,8 @@ import ../contracts/requests
proc newSalesAgent*(sales: Sales,
requestId: RequestId,
slotIndex: UInt256,
availability: ?Availability,
slotIndex: ?UInt256,
request: ?StorageRequest): SalesAgent =
SalesAgent(
sales: sales,

View File

@ -32,7 +32,7 @@ type
ask*: StorageAsk
availability*: ?Availability # TODO: when availability persistence is added, change this to not optional
request*: ?StorageRequest
slotIndex*: ?UInt256 # TODO: disallow optional; SalesAgents should always have a slotIndex
slotIndex*: UInt256
failed*: market.Subscription
fulfilled*: market.Subscription
slotFilled*: market.Subscription

View File

@ -264,8 +264,8 @@ suite "Sales state machine":
proc newSalesAgent(slotIdx: UInt256 = 0.u256): SalesAgent =
let agent = sales.newSalesAgent(request.id,
slotIdx,
some availability,
some slotIdx,
some request)
return agent
@ -455,7 +455,7 @@ suite "Sales state machine":
market.requested.add request
market.state[request.id] = RequestState.New
await agent.switchAsync(SaleDownloading())
market.fillSlot(request.id, !agent.slotIndex, proof, Address.example)
market.fillSlot(request.id, agent.slotIndex, proof, Address.example)
await sleepAsync chronos.seconds(2)
let state = (agent.state as SaleErrored)
@ -472,7 +472,7 @@ suite "Sales state machine":
market.requested.add request
market.state[request.id] = RequestState.New
await agent.switchAsync(SaleProving())
market.fillSlot(request.id, !agent.slotIndex, proof, Address.example)
market.fillSlot(request.id, agent.slotIndex, proof, Address.example)
await sleepAsync chronos.seconds(2)
let state = (agent.state as SaleErrored)
@ -488,7 +488,7 @@ suite "Sales state machine":
await agent.start(request.ask.slots)
market.requested.add request
market.state[request.id] = RequestState.New
market.fillSlot(request.id, !agent.slotIndex, proof, Address.example)
market.fillSlot(request.id, agent.slotIndex, proof, Address.example)
await agent.switchAsync(SaleFilling())
await sleepAsync chronos.seconds(2)
@ -519,7 +519,7 @@ suite "Sales state machine":
await agent.start(request.ask.slots)
market.requested.add request
market.state[request.id] = RequestState.New
await fillSlot(!agent.slotIndex)
await fillSlot(agent.slotIndex)
await agent.switchAsync(SaleDownloading())
market.emitRequestFulfilled(request.id)
await sleepAsync chronos.seconds(2)