Skip to content

Commit c9d21fc

Browse files
committed
lnd: introduce separate payment db on the server level.
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 35ee3b9 commit c9d21fc

File tree

2 files changed

+19
-3
lines changed

2 files changed

+19
-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: 7 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
@@ -1081,9 +1087,7 @@ func newServer(cfg *Config, listenAddrs []net.Addr,
10811087
PathFindingConfig: pathFindingConfig,
10821088
}
10831089

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

10881092
strictPruning := cfg.Bitcoin.Node == "neutrino" ||
10891093
cfg.Routing.StrictZombiePruning

0 commit comments

Comments
 (0)