lncfg: add configuration for user specified db backend

This commit extends lncfg to support user specified database backend.
This supports configuration for both bolt and etcd (while only allowing
one or the other).
This commit is contained in:
Andras Banki-Horvath
2020-03-13 17:05:28 +01:00
parent 859a457e48
commit 9d57c1a6b4
3 changed files with 99 additions and 6 deletions

8
lnd.go
View File

@@ -247,10 +247,6 @@ func Main(cfg *Config, lisCfg ListenerCfg, shutdownChan <-chan struct{}) error {
}
// Create the network-segmented directory for the channel database.
graphDir := filepath.Join(cfg.DataDir,
defaultGraphSubDirname,
normalizeNetwork(activeNetParams.Name))
ltndLog.Infof("Opening the main database, this might take a few " +
"minutes...")
@@ -258,7 +254,7 @@ func Main(cfg *Config, lisCfg ListenerCfg, shutdownChan <-chan struct{}) error {
// network related metadata.
startOpenTime := time.Now()
chanDB, err := channeldb.Open(
graphDir,
cfg.localDatabaseDir(),
channeldb.OptionSetRejectCacheSize(cfg.Caches.RejectCacheSize),
channeldb.OptionSetChannelCacheSize(cfg.Caches.ChannelCacheSize),
channeldb.OptionSetSyncFreelist(cfg.SyncFreelist),
@@ -493,7 +489,7 @@ func Main(cfg *Config, lisCfg ListenerCfg, shutdownChan <-chan struct{}) error {
var towerClientDB *wtdb.ClientDB
if cfg.WtClient.Active {
var err error
towerClientDB, err = wtdb.OpenClientDB(graphDir)
towerClientDB, err = wtdb.OpenClientDB(cfg.localDatabaseDir())
if err != nil {
err := fmt.Errorf("unable to open watchtower client "+
"database: %v", err)