config: expose the InvoiceDB interface in DatabaseInstances

By now the only implementation is still the one in channeldb but other
project can use their custom implementations if needed.
This commit is contained in:
positiveblue 2022-12-19 06:38:15 -08:00
parent 5ff5225245
commit 824e792dc2
No known key found for this signature in database
GPG Key ID: 4FFF2510928804DC
2 changed files with 11 additions and 1 deletions

View File

@ -25,6 +25,7 @@ import (
"github.com/lightningnetwork/lnd/blockcache"
"github.com/lightningnetwork/lnd/chainreg"
"github.com/lightningnetwork/lnd/channeldb"
"github.com/lightningnetwork/lnd/invoices"
"github.com/lightningnetwork/lnd/keychain"
"github.com/lightningnetwork/lnd/kvdb"
"github.com/lightningnetwork/lnd/lncfg"
@ -764,6 +765,9 @@ type DatabaseInstances struct {
// HeightHintDB is the database that stores height hints for spends.
HeightHintDB kvdb.Backend
// InvoiceDB is the database that stores information about invoices.
InvoiceDB invoices.InvoiceDB
// MacaroonDB is the database that stores macaroon root keys.
MacaroonDB kvdb.Backend
@ -915,6 +919,12 @@ func (d *DefaultDatabaseBuilder) BuildDatabase(
// using the same struct (and DB backend) instance.
dbs.ChanStateDB = dbs.GraphDB
// For now the only InvoiceDB implementation is the *channeldb.DB.
//
// TODO(positiveblue): use a sql first implementation for this
// interface.
dbs.InvoiceDB = dbs.GraphDB
// Wrap the watchtower client DB and make sure we clean up.
if cfg.WtClient.Active {
dbs.TowerClientDB, err = wtdb.OpenClientDB(

View File

@ -614,7 +614,7 @@ func newServer(cfg *Config, listenAddrs []net.Addr,
uint32(currentHeight), currentHash, cc.ChainNotifier,
)
s.invoices = invoices.NewRegistry(
dbs.ChanStateDB, expiryWatcher, &registryConfig,
dbs.InvoiceDB, expiryWatcher, &registryConfig,
)
s.htlcNotifier = htlcswitch.NewHtlcNotifier(time.Now)