channeldb/invoices: continue cancel loop early
This commit is contained in:
parent
fc9af92dd9
commit
5f34880040
@ -1816,23 +1816,24 @@ 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.
|
|
||||||
if _, added := update.AddHtlcs[key]; added {
|
|
||||||
return nil, fmt.Errorf("added htlc %v canceled",
|
|
||||||
key)
|
|
||||||
}
|
|
||||||
|
|
||||||
err := cancelSingleHtlc(now, htlc, newState)
|
|
||||||
if err != nil {
|
|
||||||
return nil, err
|
|
||||||
}
|
|
||||||
|
|
||||||
// Delete processed cancel action, so that we can check
|
|
||||||
// later that there are no actions left.
|
|
||||||
delete(cancelHtlcs, key)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Consistency check to verify that there is no overlap between
|
||||||
|
// the add and cancel sets.
|
||||||
|
if _, added := update.AddHtlcs[key]; added {
|
||||||
|
return nil, fmt.Errorf("added htlc %v canceled", key)
|
||||||
|
}
|
||||||
|
|
||||||
|
err := cancelSingleHtlc(now, htlc, newState)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
// Delete processed cancel action, so that we can check later
|
||||||
|
// that there are no actions left.
|
||||||
|
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
|
||||||
|
Loading…
Reference in New Issue
Block a user