swarm/network: cmdline network id highest precedence

Already fixed in previous commits, but separate commit for this issue requested.
Added comments to explain why test against 0 appears twice
fixes #3444
fixes #3494
This commit is contained in:
nolash 2017-01-18 23:44:31 +02:00
parent 6dbde1f889
commit 2f8a3dde62

View file

@ -86,6 +86,7 @@ func NewConfig(path string, contract common.Address, prvKey *ecdsa.PrivateKey, n
} }
data, err = ioutil.ReadFile(confpath) data, err = ioutil.ReadFile(confpath)
// if not set in function param, then set default for swarm network, will be overwritten by config file if present
if networkId == 0 { if networkId == 0 {
self.NetworkId = network.NetworkId self.NetworkId = network.NetworkId
} }
@ -117,6 +118,7 @@ func NewConfig(path string, contract common.Address, prvKey *ecdsa.PrivateKey, n
return nil, fmt.Errorf("bzz key does not match the one in the config file %v != %v", keyhex, self.BzzKey) return nil, fmt.Errorf("bzz key does not match the one in the config file %v != %v", keyhex, self.BzzKey)
} }
// if set in function param, replace id set from config file
if networkId != 0 { if networkId != 0 {
self.NetworkId = networkId self.NetworkId = networkId
} }