lncfg+lnd: prefix etcd db with only network name instead of full path
This commit is contained in:
parent
c3fcfd1530
commit
b53475da14
@ -1102,6 +1102,10 @@ func (c *Config) localDatabaseDir() string {
|
|||||||
normalizeNetwork(activeNetParams.Name))
|
normalizeNetwork(activeNetParams.Name))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (c *Config) networkName() string {
|
||||||
|
return normalizeNetwork(activeNetParams.Name)
|
||||||
|
}
|
||||||
|
|
||||||
// CleanAndExpandPath expands environment variables and leading ~ in the
|
// CleanAndExpandPath expands environment variables and leading ~ in the
|
||||||
// passed path, cleans the result, and returns it.
|
// passed path, cleans the result, and returns it.
|
||||||
// This function is taken from https://github.com/btcsuite/btcd
|
// This function is taken from https://github.com/btcsuite/btcd
|
||||||
|
@ -2,7 +2,6 @@ package lncfg
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
||||||
"path"
|
|
||||||
|
|
||||||
"github.com/lightningnetwork/lnd/channeldb/kvdb"
|
"github.com/lightningnetwork/lnd/channeldb/kvdb"
|
||||||
)
|
)
|
||||||
@ -51,11 +50,12 @@ func (db *DB) Validate() error {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// GetBackend returns a kvdb.Backend as set in the DB config.
|
// GetBackend returns a kvdb.Backend as set in the DB config.
|
||||||
func (db *DB) GetBackend(dbPath string) (kvdb.Backend, error) {
|
func (db *DB) GetBackend(dbPath string, networkName string) (
|
||||||
|
kvdb.Backend, error) {
|
||||||
|
|
||||||
if db.Backend == etcdBackend {
|
if db.Backend == etcdBackend {
|
||||||
// Prefix will separate key/values in the db.
|
// Prefix will separate key/values in the db.
|
||||||
prefix := path.Join(dbPath, dbName)
|
return kvdb.GetEtcdBackend(networkName, db.Etcd)
|
||||||
return kvdb.GetEtcdBackend(prefix, db.Etcd)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return kvdb.GetBoltBackend(dbPath, dbName, db.Bolt.NoFreeListSync)
|
return kvdb.GetBoltBackend(dbPath, dbName, db.Bolt.NoFreeListSync)
|
||||||
|
4
lnd.go
4
lnd.go
@ -250,7 +250,9 @@ func Main(cfg *Config, lisCfg ListenerCfg, shutdownChan <-chan struct{}) error {
|
|||||||
ltndLog.Infof("Opening the main database, this might take a few " +
|
ltndLog.Infof("Opening the main database, this might take a few " +
|
||||||
"minutes...")
|
"minutes...")
|
||||||
|
|
||||||
chanDbBackend, err := cfg.DB.GetBackend(cfg.localDatabaseDir())
|
chanDbBackend, err := cfg.DB.GetBackend(
|
||||||
|
cfg.localDatabaseDir(), cfg.networkName(),
|
||||||
|
)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
ltndLog.Error(err)
|
ltndLog.Error(err)
|
||||||
return err
|
return err
|
||||||
|
Loading…
Reference in New Issue
Block a user