multi: use kvdb.Backend for height hint DB

In order to separate our databases more clearly, we refactor the height
hint cache DB to use a kvdb backend instead of the channel DB instance
directly.
This commit is contained in:
Oliver Gugger committed 2021-08-04 14:55:51 +02:00
1 parent 9138c8abac
commit c4917ae7fc
4 files changed
+26 -14

No files matched your search

+8 -4
View File
@@ -43,6 +43,7 @@ import (
"github.com/lightningnetwork/lnd/chanacceptor"
"github.com/lightningnetwork/lnd/channeldb"
"github.com/lightningnetwork/lnd/keychain"
"github.com/lightningnetwork/lnd/kvdb"
"github.com/lightningnetwork/lnd/lncfg"
"github.com/lightningnetwork/lnd/lnrpc"
"github.com/lightningnetwork/lnd/lnwallet"
@@ -706,7 +707,7 @@ func Main(cfg *Config, lisCfg ListenerCfg, interceptor signal.Interceptor) error
LitecoindMode: cfg.LitecoindMode,
BtcdMode: cfg.BtcdMode,
LtcdMode: cfg.LtcdMode,
HeightHintDB: dbs.graphDB,
HeightHintDB: dbs.heightHintDB,
ChanStateDB: dbs.chanStateDB,
PrivateWalletPw: privateWalletPw,
PublicWalletPw: publicWalletPw,
@@ -1624,8 +1625,9 @@ func waitForWalletPassword(cfg *Config,
// databaseInstances is a struct that holds all instances to the actual
// databases that are used in lnd.
type databaseInstances struct {
graphDB *channeldb.DB
chanStateDB *channeldb.DB
graphDB *channeldb.DB
chanStateDB *channeldb.DB
heightHintDB kvdb.Backend
}
// initializeDatabases extracts the current databases that we'll use for normal
@@ -1655,7 +1657,9 @@ func initializeDatabases(ctx context.Context,
// If the remoteDB is nil, then we'll just open a local DB as normal,
// having the remote and local pointer be the exact same instance.
var (
dbs = &databaseInstances{}
dbs = &databaseInstances{
heightHintDB: databaseBackends.HeightHintDB,
}
closeFuncs []func()
)
if databaseBackends.ChanStateDB == nil {