mirror of
https://github.com/logos-storage/logos-storage-nim.git
synced 2026-02-27 00:43:34 +00:00
Remove the returnedCollateral when the slot is not filled by the host
This commit is contained in:
parent
05e0192563
commit
2ae617d662
@ -31,24 +31,22 @@ method run*(
|
||||
raiseAssert "no sale request"
|
||||
|
||||
try:
|
||||
debug "Collecting collateral and partial payout",
|
||||
requestId = data.requestId, slotIndex = data.slotIndex
|
||||
|
||||
# The returnedCollateral is needed even if the slot is not filled by the host
|
||||
# because a reservation could be created and the collateral assigned
|
||||
# to that reservation. So if the slot is not filled by that host,
|
||||
# the reservation will be deleted during cleanup and the collateral
|
||||
# must be returned to the host.
|
||||
let slot = Slot(request: request, slotIndex: data.slotIndex)
|
||||
let currentCollateral = await market.currentCollateral(slot.id)
|
||||
let returnedCollateral = currentCollateral.some
|
||||
var returnedCollateral = UInt256.none
|
||||
|
||||
if await slotIsFilledByMe(market, data.requestId, data.slotIndex):
|
||||
debug "Collecting collateral and partial payout",
|
||||
requestId = data.requestId, slotIndex = data.slotIndex
|
||||
|
||||
let slot = Slot(request: request, slotIndex: data.slotIndex)
|
||||
let currentCollateral = await market.currentCollateral(slot.id)
|
||||
|
||||
try:
|
||||
await market.freeSlot(slot.id)
|
||||
except SlotStateMismatchError as e:
|
||||
warn "Failed to free slot because slot is already free", error = e.msg
|
||||
|
||||
returnedCollateral = currentCollateral.some
|
||||
|
||||
if onClear =? agent.context.onClear and request =? data.request:
|
||||
onClear(request, data.slotIndex)
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user