mirror of
https://github.com/lightningnetwork/lnd.git
synced 2025-09-06 17:47:01 +02:00
multi: extend InvoiceDB
methods with a context argument (#8066)
* multi: extend InvoiceDB methods with a context argument This commit adds a context to InvoiceDB's methods. Along this refactor we also extend InvoiceRegistry methods with contexts where it makes sense. This change is essential to be able to provide kvdb and sqldb implementations for InvoiceDB. * channeldb: restrict invoice tests to only use an InvoiceDB instance * docs: update release notes for 0.18.0
This commit is contained in:
committed by
GitHub
parent
9478b85e59
commit
ad5cd9c8bb
@@ -2,6 +2,7 @@ package htlcswitch
|
||||
|
||||
import (
|
||||
"bytes"
|
||||
"context"
|
||||
"crypto/sha256"
|
||||
"encoding/binary"
|
||||
"fmt"
|
||||
@@ -979,16 +980,16 @@ func newMockRegistry(minDelta uint32) *mockInvoiceRegistry {
|
||||
}
|
||||
}
|
||||
|
||||
func (i *mockInvoiceRegistry) LookupInvoice(rHash lntypes.Hash) (
|
||||
invoices.Invoice, error) {
|
||||
func (i *mockInvoiceRegistry) LookupInvoice(ctx context.Context,
|
||||
rHash lntypes.Hash) (invoices.Invoice, error) {
|
||||
|
||||
return i.registry.LookupInvoice(rHash)
|
||||
return i.registry.LookupInvoice(ctx, rHash)
|
||||
}
|
||||
|
||||
func (i *mockInvoiceRegistry) SettleHodlInvoice(
|
||||
preimage lntypes.Preimage) error {
|
||||
ctx context.Context, preimage lntypes.Preimage) error {
|
||||
|
||||
return i.registry.SettleHodlInvoice(preimage)
|
||||
return i.registry.SettleHodlInvoice(ctx, preimage)
|
||||
}
|
||||
|
||||
func (i *mockInvoiceRegistry) NotifyExitHopHtlc(rhash lntypes.Hash,
|
||||
@@ -1010,14 +1011,16 @@ func (i *mockInvoiceRegistry) NotifyExitHopHtlc(rhash lntypes.Hash,
|
||||
return event, nil
|
||||
}
|
||||
|
||||
func (i *mockInvoiceRegistry) CancelInvoice(payHash lntypes.Hash) error {
|
||||
return i.registry.CancelInvoice(payHash)
|
||||
func (i *mockInvoiceRegistry) CancelInvoice(ctx context.Context,
|
||||
payHash lntypes.Hash) error {
|
||||
|
||||
return i.registry.CancelInvoice(ctx, payHash)
|
||||
}
|
||||
|
||||
func (i *mockInvoiceRegistry) AddInvoice(invoice invoices.Invoice,
|
||||
paymentHash lntypes.Hash) error {
|
||||
func (i *mockInvoiceRegistry) AddInvoice(ctx context.Context,
|
||||
invoice invoices.Invoice, paymentHash lntypes.Hash) error {
|
||||
|
||||
_, err := i.registry.AddInvoice(&invoice, paymentHash)
|
||||
_, err := i.registry.AddInvoice(ctx, &invoice, paymentHash)
|
||||
return err
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user