loop: fix cost migration for pending swaps

This commit is contained in:
Andras Banki-Horvath 2024-06-04 18:43:04 +02:00
parent 28c09bec68
commit 9cacd8eb75
No known key found for this signature in database
GPG key ID: 80E5375C094198D8

View file

@ -150,11 +150,21 @@ func MigrateLoopOutCosts(ctx context.Context, lnd lndclient.LndServices,
// costs in the database.
updatedCosts := make(map[lntypes.Hash]loopdb.SwapCost)
for _, loopOutSwap := range loopOutSwaps {
if loopOutSwap.State().State.IsPending() {
continue
}
cost, err := CalculateLoopOutCost(
lnd.ChainParams, loopOutSwap, paymentFees,
)
if err != nil {
return err
// We don't want to fail loopd because of any old swap
// that we're unable to calculate the cost for. We'll
// warn though so that we can investigate further.
log.Warnf("Unable to calculate cost for swap %v: %v",
loopOutSwap.Hash, err)
continue
}
_, ok := updatedCosts[loopOutSwap.Hash]