[sales] make slotIndex non-optional
This commit is contained in:
parent
8a8e7aed70
commit
b017359d13
|
@ -75,8 +75,8 @@ proc handleRequest(sales: Sales,
|
||||||
let agent = newSalesAgent(
|
let agent = newSalesAgent(
|
||||||
sales,
|
sales,
|
||||||
requestId,
|
requestId,
|
||||||
|
slotIndex,
|
||||||
availability,
|
availability,
|
||||||
some slotIndex,
|
|
||||||
none StorageRequest
|
none StorageRequest
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -103,8 +103,8 @@ proc load*(sales: Sales) {.async.} =
|
||||||
let agent = newSalesAgent(
|
let agent = newSalesAgent(
|
||||||
sales,
|
sales,
|
||||||
request.id,
|
request.id,
|
||||||
|
slotIndex,
|
||||||
availability,
|
availability,
|
||||||
some slotIndex,
|
|
||||||
some request)
|
some request)
|
||||||
|
|
||||||
await agent.start(request.ask.slots)
|
await agent.start(request.ask.slots)
|
||||||
|
|
|
@ -6,8 +6,8 @@ import ../contracts/requests
|
||||||
|
|
||||||
proc newSalesAgent*(sales: Sales,
|
proc newSalesAgent*(sales: Sales,
|
||||||
requestId: RequestId,
|
requestId: RequestId,
|
||||||
|
slotIndex: UInt256,
|
||||||
availability: ?Availability,
|
availability: ?Availability,
|
||||||
slotIndex: ?UInt256,
|
|
||||||
request: ?StorageRequest): SalesAgent =
|
request: ?StorageRequest): SalesAgent =
|
||||||
SalesAgent(
|
SalesAgent(
|
||||||
sales: sales,
|
sales: sales,
|
||||||
|
|
|
@ -32,7 +32,7 @@ type
|
||||||
ask*: StorageAsk
|
ask*: StorageAsk
|
||||||
availability*: ?Availability # TODO: when availability persistence is added, change this to not optional
|
availability*: ?Availability # TODO: when availability persistence is added, change this to not optional
|
||||||
request*: ?StorageRequest
|
request*: ?StorageRequest
|
||||||
slotIndex*: ?UInt256 # TODO: disallow optional; SalesAgents should always have a slotIndex
|
slotIndex*: UInt256
|
||||||
failed*: market.Subscription
|
failed*: market.Subscription
|
||||||
fulfilled*: market.Subscription
|
fulfilled*: market.Subscription
|
||||||
slotFilled*: market.Subscription
|
slotFilled*: market.Subscription
|
||||||
|
|
|
@ -264,8 +264,8 @@ suite "Sales state machine":
|
||||||
|
|
||||||
proc newSalesAgent(slotIdx: UInt256 = 0.u256): SalesAgent =
|
proc newSalesAgent(slotIdx: UInt256 = 0.u256): SalesAgent =
|
||||||
let agent = sales.newSalesAgent(request.id,
|
let agent = sales.newSalesAgent(request.id,
|
||||||
|
slotIdx,
|
||||||
some availability,
|
some availability,
|
||||||
some slotIdx,
|
|
||||||
some request)
|
some request)
|
||||||
return agent
|
return agent
|
||||||
|
|
||||||
|
@ -455,7 +455,7 @@ suite "Sales state machine":
|
||||||
market.requested.add request
|
market.requested.add request
|
||||||
market.state[request.id] = RequestState.New
|
market.state[request.id] = RequestState.New
|
||||||
await agent.switchAsync(SaleDownloading())
|
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)
|
await sleepAsync chronos.seconds(2)
|
||||||
|
|
||||||
let state = (agent.state as SaleErrored)
|
let state = (agent.state as SaleErrored)
|
||||||
|
@ -472,7 +472,7 @@ suite "Sales state machine":
|
||||||
market.requested.add request
|
market.requested.add request
|
||||||
market.state[request.id] = RequestState.New
|
market.state[request.id] = RequestState.New
|
||||||
await agent.switchAsync(SaleProving())
|
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)
|
await sleepAsync chronos.seconds(2)
|
||||||
|
|
||||||
let state = (agent.state as SaleErrored)
|
let state = (agent.state as SaleErrored)
|
||||||
|
@ -488,7 +488,7 @@ suite "Sales state machine":
|
||||||
await agent.start(request.ask.slots)
|
await agent.start(request.ask.slots)
|
||||||
market.requested.add request
|
market.requested.add request
|
||||||
market.state[request.id] = RequestState.New
|
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 agent.switchAsync(SaleFilling())
|
||||||
await sleepAsync chronos.seconds(2)
|
await sleepAsync chronos.seconds(2)
|
||||||
|
|
||||||
|
@ -519,7 +519,7 @@ suite "Sales state machine":
|
||||||
await agent.start(request.ask.slots)
|
await agent.start(request.ask.slots)
|
||||||
market.requested.add request
|
market.requested.add request
|
||||||
market.state[request.id] = RequestState.New
|
market.state[request.id] = RequestState.New
|
||||||
await fillSlot(!agent.slotIndex)
|
await fillSlot(agent.slotIndex)
|
||||||
await agent.switchAsync(SaleDownloading())
|
await agent.switchAsync(SaleDownloading())
|
||||||
market.emitRequestFulfilled(request.id)
|
market.emitRequestFulfilled(request.id)
|
||||||
await sleepAsync chronos.seconds(2)
|
await sleepAsync chronos.seconds(2)
|
||||||
|
|
Loading…
Reference in New Issue