mirror of
https://github.com/codex-storage/nim-codex.git
synced 2025-02-22 09:38:12 +00:00
[marketplace] support slotIndex no longer optional
Previously, SalesAgent.slotIndex had been moved to not optional. However, there were still many places where optionality was assumed. This commit removes those assumuptions.
This commit is contained in:
parent
c2a8cea91b
commit
f4d5361ca8
@ -87,16 +87,15 @@ proc subscribeFailure*(agent: SalesAgent) {.async.} =
|
||||
proc subscribeSlotFilled*(agent: SalesAgent) {.async.} =
|
||||
let market = agent.sales.market
|
||||
|
||||
without slotIndex =? agent.slotIndex:
|
||||
raiseAssert "no slot selected"
|
||||
|
||||
proc onSlotFilled(requestId: RequestId,
|
||||
slotIndex: UInt256) {.async.} =
|
||||
without state =? (agent.state as SaleState):
|
||||
return
|
||||
|
||||
await agent.slotFilled.unsubscribe()
|
||||
await state.onSlotFilled(requestId, slotIndex)
|
||||
await state.onSlotFilled(requestId, agent.slotIndex)
|
||||
|
||||
agent.slotFilled =
|
||||
await market.subscribeSlotFilled(agent.requestId, slotIndex, onSlotFilled)
|
||||
await market.subscribeSlotFilled(agent.requestId,
|
||||
agent.slotIndex,
|
||||
onSlotFilled)
|
||||
|
@ -34,16 +34,13 @@ method enterAsync(state: SaleDownloading) {.async.} =
|
||||
without onStore =? agent.sales.onStore:
|
||||
raiseAssert "onStore callback not set"
|
||||
|
||||
without slotIndex =? agent.slotIndex:
|
||||
raiseAssert "no slot selected"
|
||||
|
||||
without request =? agent.request:
|
||||
raiseAssert "no sale request"
|
||||
|
||||
if availability =? agent.availability:
|
||||
agent.sales.remove(availability)
|
||||
|
||||
await onStore(request, slotIndex, agent.availability)
|
||||
await onStore(request, agent.slotIndex, agent.availability)
|
||||
await state.switchAsync(SaleProving())
|
||||
|
||||
except CancelledError:
|
||||
|
@ -24,10 +24,7 @@ method enterAsync(state: SaleFilled) {.async.} =
|
||||
try:
|
||||
let market = agent.sales.market
|
||||
|
||||
without slotIndex =? agent.slotIndex:
|
||||
raiseAssert "no slot selected"
|
||||
|
||||
let host = await market.getHost(agent.requestId, slotIndex)
|
||||
let host = await market.getHost(agent.requestId, agent.slotIndex)
|
||||
let me = await market.getSigner()
|
||||
if host == me.some:
|
||||
await state.switchAsync(SaleFinished())
|
||||
|
@ -30,10 +30,7 @@ method enterAsync(state: SaleFilling) {.async.} =
|
||||
try:
|
||||
let market = agent.sales.market
|
||||
|
||||
without slotIndex =? agent.slotIndex:
|
||||
raiseAssert "no slot selected"
|
||||
|
||||
await market.fillSlot(agent.requestId, slotIndex, state.proof)
|
||||
await market.fillSlot(agent.requestId, agent.slotIndex, state.proof)
|
||||
|
||||
except CancelledError:
|
||||
discard
|
||||
|
@ -29,13 +29,10 @@ method enterAsync(state: SaleProving) {.async.} =
|
||||
without request =? agent.request:
|
||||
raiseAssert "no sale request"
|
||||
|
||||
without slotIndex =? agent.slotIndex:
|
||||
raiseAssert "no slot selected"
|
||||
|
||||
without onProve =? agent.sales.onProve:
|
||||
raiseAssert "onProve callback not set"
|
||||
|
||||
let proof = await onProve(request, slotIndex)
|
||||
let proof = await onProve(request, agent.slotIndex)
|
||||
await state.switchAsync(SaleFilling(proof: proof))
|
||||
|
||||
except CancelledError:
|
||||
|
Loading…
x
Reference in New Issue
Block a user