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
1 changed files with 6 additions and 6 deletions

View File

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