config: separate chain directory
This commit is contained in:
parent
21c29c33d7
commit
6286a93cf5
28
config.go
28
config.go
@ -27,6 +27,8 @@ import (
|
|||||||
const (
|
const (
|
||||||
defaultConfigFilename = "lnd.conf"
|
defaultConfigFilename = "lnd.conf"
|
||||||
defaultDataDirname = "data"
|
defaultDataDirname = "data"
|
||||||
|
defaultChainSubDirname = "chain"
|
||||||
|
defaultGraphSubDirname = "graph"
|
||||||
defaultTLSCertFilename = "tls.cert"
|
defaultTLSCertFilename = "tls.cert"
|
||||||
defaultTLSKeyFilename = "tls.key"
|
defaultTLSKeyFilename = "tls.key"
|
||||||
defaultAdminMacFilename = "admin.macaroon"
|
defaultAdminMacFilename = "admin.macaroon"
|
||||||
@ -328,7 +330,10 @@ func loadConfig() (*config, error) {
|
|||||||
"ltcd: %v", err)
|
"ltcd: %v", err)
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
cfg.Litecoin.ChainDir = filepath.Join(cfg.DataDir, litecoinChain.String())
|
|
||||||
|
cfg.Litecoin.ChainDir = filepath.Join(cfg.DataDir,
|
||||||
|
defaultChainSubDirname,
|
||||||
|
litecoinChain.String())
|
||||||
|
|
||||||
// Finally we'll register the litecoin chain as our current
|
// Finally we'll register the litecoin chain as our current
|
||||||
// primary chain.
|
// primary chain.
|
||||||
@ -388,7 +393,9 @@ func loadConfig() (*config, error) {
|
|||||||
// No need to get RPC parameters.
|
// No need to get RPC parameters.
|
||||||
}
|
}
|
||||||
|
|
||||||
cfg.Bitcoin.ChainDir = filepath.Join(cfg.DataDir, bitcoinChain.String())
|
cfg.Bitcoin.ChainDir = filepath.Join(cfg.DataDir,
|
||||||
|
defaultChainSubDirname,
|
||||||
|
bitcoinChain.String())
|
||||||
|
|
||||||
// Finally we'll register the bitcoin chain as our current
|
// Finally we'll register the bitcoin chain as our current
|
||||||
// primary chain.
|
// primary chain.
|
||||||
@ -431,16 +438,13 @@ func loadConfig() (*config, error) {
|
|||||||
// TODO(roasbeef): when we go full multi-chain remove the additional
|
// TODO(roasbeef): when we go full multi-chain remove the additional
|
||||||
// namespacing on the target chain.
|
// namespacing on the target chain.
|
||||||
cfg.DataDir = cleanAndExpandPath(cfg.DataDir)
|
cfg.DataDir = cleanAndExpandPath(cfg.DataDir)
|
||||||
cfg.DataDir = filepath.Join(cfg.DataDir, activeNetParams.Name)
|
|
||||||
cfg.DataDir = filepath.Join(cfg.DataDir,
|
|
||||||
registeredChains.primaryChain.String())
|
|
||||||
|
|
||||||
// Append the network type to the log directory so it is "namespaced"
|
// Append the network type to the log directory so it is "namespaced"
|
||||||
// per network in the same fashion as the data directory.
|
// per network in the same fashion as the data directory.
|
||||||
cfg.LogDir = cleanAndExpandPath(cfg.LogDir)
|
cfg.LogDir = cleanAndExpandPath(cfg.LogDir)
|
||||||
cfg.LogDir = filepath.Join(cfg.LogDir, activeNetParams.Name)
|
|
||||||
cfg.LogDir = filepath.Join(cfg.LogDir,
|
cfg.LogDir = filepath.Join(cfg.LogDir,
|
||||||
registeredChains.primaryChain.String())
|
registeredChains.PrimaryChain().String(),
|
||||||
|
normalizeNetwork(activeNetParams.Name))
|
||||||
|
|
||||||
// Ensure that the paths to the TLS key and certificate files are
|
// Ensure that the paths to the TLS key and certificate files are
|
||||||
// expanded and cleaned.
|
// expanded and cleaned.
|
||||||
@ -916,3 +920,13 @@ func enforceSafeAuthentication(addrs []string, macaroonsActive bool) error {
|
|||||||
|
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// normalizeNetwork returns the common name of a network type used to create
|
||||||
|
// file paths. This allows differently versioned networks to use the same path.
|
||||||
|
func normalizeNetwork(network string) string {
|
||||||
|
if strings.HasPrefix(network, "testnet") {
|
||||||
|
return "testnet"
|
||||||
|
}
|
||||||
|
|
||||||
|
return network
|
||||||
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user