diff --git a/config_builder.go b/config_builder.go index 3c8b122a8..35a44e2c6 100644 --- a/config_builder.go +++ b/config_builder.go @@ -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( diff --git a/server.go b/server.go index ebc513fdd..a84642f1f 100644 --- a/server.go +++ b/server.go @@ -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