invoiceregistry: promote update closure to method

This commit moves the update code into its own function as a preparation
for extending the logic further for mpp.

In order to make this change cleanly, structured result codes are
introduced. This also prepares for a future htlc notifier rpc hook that
reports htlc settle decisions to external applications.

Furthermore the awkward use of errNoUpdate as a way to signal no update
is removed.
This commit is contained in:
Joost Jager
2019-11-27 10:05:14 +01:00
parent 823b52802c
commit 915867e90f
2 changed files with 191 additions and 101 deletions

View File

@@ -1241,6 +1241,11 @@ func (d *DB) updateInvoice(hash lntypes.Hash, invoices, settleIndex *bbolt.Bucke
return &invoice, err
}
// If there is nothing to update, return early.
if update == nil {
return &invoice, nil
}
// Update invoice state.
invoice.State = update.State