lnd: introduce separate key-value payment db

We also addd this new db on the server level to use it in the
following commit to do all the payment related queries of the
rpcserver.
We add a new payment db instance on the server level. Which we
will you for the payment related queries in a following commit.
This commit is contained in:
ziggie
2025-08-01 18:07:41 +02:00
parent 84b2a94da2
commit e120110470
2 changed files with 20 additions and 3 deletions

View File

@@ -924,6 +924,10 @@ type DatabaseInstances struct {
// InvoiceDB is the database that stores information about invoices.
InvoiceDB invoices.InvoiceDB
// KVPaymentsDB is the database that stores all payment related
// information.
KVPaymentsDB *channeldb.KVPaymentsDB
// MacaroonDB is the database that stores macaroon root keys.
MacaroonDB kvdb.Backend
@@ -1215,6 +1219,14 @@ func (d *DefaultDatabaseBuilder) BuildDatabase(
return nil, nil, err
}
// Mount the payments DB which is only KV for now.
//
// TODO(ziggie): Add support for SQL payments DB.
kvPaymentsDB := channeldb.NewKVPaymentsDB(
dbs.ChanStateDB,
)
dbs.KVPaymentsDB = kvPaymentsDB
// Wrap the watchtower client DB and make sure we clean up.
if cfg.WtClient.Active {
dbs.TowerClientDB, err = wtdb.OpenClientDB(

View File

@@ -335,6 +335,12 @@ type server struct {
invoicesDB invoices.InvoiceDB
// kvPaymentsDB is the DB that contains all functions for managing
// payments.
//
// TODO(ziggie): Replace with interface.
kvPaymentsDB *channeldb.KVPaymentsDB
aliasMgr *aliasmgr.Manager
htlcSwitch *htlcswitch.Switch
@@ -678,6 +684,7 @@ func newServer(ctx context.Context, cfg *Config, listenAddrs []net.Addr,
addrSource: addrSource,
miscDB: dbs.ChanStateDB,
invoicesDB: dbs.InvoiceDB,
kvPaymentsDB: dbs.KVPaymentsDB,
cc: cc,
sigPool: lnwallet.NewSigPool(cfg.Workers.Sig, cc.Signer),
writePool: writePool,
@@ -1127,9 +1134,7 @@ func newServer(ctx context.Context, cfg *Config, listenAddrs []net.Addr,
PathFindingConfig: pathFindingConfig,
}
paymentControl := channeldb.NewKVPaymentsDB(dbs.ChanStateDB)
s.controlTower = routing.NewControlTower(paymentControl)
s.controlTower = routing.NewControlTower(dbs.KVPaymentsDB)
strictPruning := cfg.Bitcoin.Node == "neutrino" ||
cfg.Routing.StrictZombiePruning