config: set chain directory _after_ the command line+config has been parsed

This commit fixes a bug introduced by the new multi-chain features of
and which disallowed multiple nodes from beings started locally.
Previously if two local nodes were set to, the _same_ chain, then
they’d both share the same chain data directory which would prevent one
of the nodes from being able to start up properly.
This commit is contained in:
Olaoluwa Osuntokun 2017-05-02 20:28:14 -07:00
parent 6acd177c33
commit b89a39d341
No known key found for this signature in database
GPG Key ID: 9CC5B105D03521A2

View File

@ -102,14 +102,12 @@ func loadConfig() (*config, error) {
RPCPort: defaultRPCPort,
MaxPendingChannels: defaultMaxPendingChannels,
Bitcoin: &chainConfig{
RPCHost: defaultRPCHost,
ChainDir: filepath.Join(defaultDataDir, bitcoinChain.String()),
RPCCert: defaultBtcdRPCCertFile,
RPCHost: defaultRPCHost,
RPCCert: defaultBtcdRPCCertFile,
},
Litecoin: &chainConfig{
RPCHost: defaultRPCHost,
ChainDir: filepath.Join(defaultDataDir, litecoinChain.String()),
RPCCert: defaultLtcdRPCCertFile,
RPCHost: defaultRPCHost,
RPCCert: defaultLtcdRPCCertFile,
},
}
@ -190,6 +188,7 @@ func loadConfig() (*config, error) {
"ltcd: %v", err)
return nil, err
}
cfg.Litecoin.ChainDir = filepath.Join(cfg.DataDir, litecoinChain.String())
// Finally we'll register the litecoin chain as our current
// primary chain.
@ -222,6 +221,7 @@ func loadConfig() (*config, error) {
"btcd: %v", err)
return nil, err
}
cfg.Bitcoin.ChainDir = filepath.Join(cfg.DataDir, bitcoinChain.String())
// Finally we'll register the bitcoin chain as our current
// primary chain.