mirror of
https://github.com/logos-storage/logos-storage-nim.git
synced 2026-05-17 00:39:48 +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"
|
raiseAssert "no sale request"
|
||||||
|
|
||||||
try:
|
try:
|
||||||
debug "Collecting collateral and partial payout",
|
var returnedCollateral = UInt256.none
|
||||||
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
|
|
||||||
|
|
||||||
if await slotIsFilledByMe(market, data.requestId, data.slotIndex):
|
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:
|
try:
|
||||||
await market.freeSlot(slot.id)
|
await market.freeSlot(slot.id)
|
||||||
except SlotStateMismatchError as e:
|
except SlotStateMismatchError as e:
|
||||||
warn "Failed to free slot because slot is already free", error = e.msg
|
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:
|
if onClear =? agent.context.onClear and request =? data.request:
|
||||||
onClear(request, data.slotIndex)
|
onClear(request, data.slotIndex)
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user