channeldb/invoices: continue cancel loop early

This commit is contained in:
Conner Fromknecht 2021-03-03 09:59:05 -08:00
parent fc9af92dd9
commit 5f34880040
No known key found for this signature in database
GPG Key ID: E7D737B67FA592C7

@ -1816,12 +1816,14 @@ func (d *DB) updateInvoice(hash lntypes.Hash, invoices,
// Check whether this htlc needs to be canceled. If it does, // Check whether this htlc needs to be canceled. If it does,
// update the htlc state to Canceled. // update the htlc state to Canceled.
_, cancel := cancelHtlcs[key] _, cancel := cancelHtlcs[key]
if cancel { if !cancel {
// Consistency check to verify that there is no overlap continue
// between the add and cancel sets. }
// Consistency check to verify that there is no overlap between
// the add and cancel sets.
if _, added := update.AddHtlcs[key]; added { if _, added := update.AddHtlcs[key]; added {
return nil, fmt.Errorf("added htlc %v canceled", return nil, fmt.Errorf("added htlc %v canceled", key)
key)
} }
err := cancelSingleHtlc(now, htlc, newState) err := cancelSingleHtlc(now, htlc, newState)
@ -1829,11 +1831,10 @@ func (d *DB) updateInvoice(hash lntypes.Hash, invoices,
return nil, err return nil, err
} }
// Delete processed cancel action, so that we can check // Delete processed cancel action, so that we can check later
// later that there are no actions left. // that there are no actions left.
delete(cancelHtlcs, key) delete(cancelHtlcs, key)
} }
}
// Verify that we didn't get an action for htlcs that are not present on // Verify that we didn't get an action for htlcs that are not present on
// the invoice. // the invoice.