Skip to content

Commit f4a39a7

Browse files
committed
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.
1 parent da88254 commit f4a39a7

File tree

2 files changed

+20
-3
lines changed

2 files changed

+20
-3
lines changed

config_builder.go

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -924,6 +924,10 @@ type DatabaseInstances struct {
924924
// InvoiceDB is the database that stores information about invoices.
925925
InvoiceDB invoices.InvoiceDB
926926

927+
// KVPaymentsDB is the database that stores all payment related
928+
// information.
929+
KVPaymentsDB *channeldb.KVPaymentsDB
930+
927931
// MacaroonDB is the database that stores macaroon root keys.
928932
MacaroonDB kvdb.Backend
929933

@@ -1184,6 +1188,14 @@ func (d *DefaultDatabaseBuilder) BuildDatabase(
11841188
dbs.InvoiceDB = dbs.ChanStateDB
11851189
}
11861190

1191+
// Mount the payments DB which is only KV for now.
1192+
//
1193+
// TODO(ziggie): Add support for SQL payments DB.
1194+
kvPaymentsDB := channeldb.NewKVPaymentsDB(
1195+
dbs.ChanStateDB,
1196+
)
1197+
dbs.KVPaymentsDB = kvPaymentsDB
1198+
11871199
// Wrap the watchtower client DB and make sure we clean up.
11881200
if cfg.WtClient.Active {
11891201
dbs.TowerClientDB, err = wtdb.OpenClientDB(

server.go

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -317,6 +317,12 @@ type server struct {
317317

318318
invoicesDB invoices.InvoiceDB
319319

320+
// kvPaymentsDB is the DB that contains all functions for managing
321+
// payments.
322+
//
323+
// TODO(ziggie): Replace with interface.
324+
kvPaymentsDB *channeldb.KVPaymentsDB
325+
320326
aliasMgr *aliasmgr.Manager
321327

322328
htlcSwitch *htlcswitch.Switch
@@ -658,6 +664,7 @@ func newServer(cfg *Config, listenAddrs []net.Addr,
658664
addrSource: addrSource,
659665
miscDB: dbs.ChanStateDB,
660666
invoicesDB: dbs.InvoiceDB,
667+
kvPaymentsDB: dbs.KVPaymentsDB,
661668
cc: cc,
662669
sigPool: lnwallet.NewSigPool(cfg.Workers.Sig, cc.Signer),
663670
writePool: writePool,
@@ -1081,9 +1088,7 @@ func newServer(cfg *Config, listenAddrs []net.Addr,
10811088
PathFindingConfig: pathFindingConfig,
10821089
}
10831090

1084-
paymentControl := channeldb.NewKVPaymentsDB(dbs.ChanStateDB)
1085-
1086-
s.controlTower = routing.NewControlTower(paymentControl)
1091+
s.controlTower = routing.NewControlTower(dbs.KVPaymentsDB)
10871092

10881093
strictPruning := cfg.Bitcoin.Node == "neutrino" ||
10891094
cfg.Routing.StrictZombiePruning

0 commit comments

Comments
 (0)