diff --git a/invoices/invoiceregistry.go b/invoices/invoiceregistry.go index 9ab1a65b..e83a21b6 100644 --- a/invoices/invoiceregistry.go +++ b/invoices/invoiceregistry.go @@ -780,11 +780,6 @@ func (i *InvoiceRegistry) NotifyExitHopHtlc(rHash lntypes.Hash, mpp := payload.MultiPath() - debugLog := func(s string) { - log.Debugf("Invoice(%x): %v, amt=%v, expiry=%v, circuit=%v, "+ - "mpp=%v", rHash[:], s, amtPaid, expiry, circuitKey, mpp) - } - // Create the update context containing the relevant details of the // incoming htlc. updateCtx := invoiceUpdateCtx{ @@ -804,7 +799,7 @@ func (i *InvoiceRegistry) NotifyExitHopHtlc(rHash lntypes.Hash, if i.cfg.AcceptKeySend { err := i.processKeySend(updateCtx) if err != nil { - debugLog(fmt.Sprintf("keysend error: %v", err)) + updateCtx.log(fmt.Sprintf("keysend error: %v", err)) return NewFailureResolution( circuitKey, currentHeight, ResultKeySendError, @@ -852,11 +847,11 @@ func (i *InvoiceRegistry) NotifyExitHopHtlc(rHash lntypes.Hash, case nil: default: - debugLog(err.Error()) + updateCtx.log(err.Error()) return nil, err } - debugLog(result.String()) + updateCtx.log(result.String()) if updateSubscribers { i.notifyClients(rHash, invoice, invoice.State) diff --git a/invoices/update.go b/invoices/update.go index 2e05b398..e6feaba0 100644 --- a/invoices/update.go +++ b/invoices/update.go @@ -180,6 +180,12 @@ type invoiceUpdateCtx struct { mpp *record.MPP } +// log logs a message specific to this update context. +func (i *invoiceUpdateCtx) log(s string) { + log.Debugf("Invoice(%x): %v, amt=%v, expiry=%v, circuit=%v, mpp=%v", + i.hash[:], s, i.amtPaid, i.expiry, i.circuitKey, i.mpp) +} + // updateInvoice is a callback for DB.UpdateInvoice that contains the invoice // settlement logic. func updateInvoice(ctx *invoiceUpdateCtx, inv *channeldb.Invoice) (