aboutsummaryrefslogtreecommitdiffstats
path: root/swarm/api/config.go
diff options
context:
space:
mode:
Diffstat (limited to 'swarm/api/config.go')
-rw-r--r--swarm/api/config.go14
1 files changed, 14 insertions, 0 deletions
diff --git a/swarm/api/config.go b/swarm/api/config.go
index b4c6e3d4a..23a855500 100644
--- a/swarm/api/config.go
+++ b/swarm/api/config.go
@@ -85,10 +85,17 @@ func NewConfig(path string, contract common.Address, prvKey *ecdsa.PrivateKey, n
NetworkId: networkId,
}
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 {
+ self.NetworkId = network.NetworkId
+ }
+
if err != nil {
if !os.IsNotExist(err) {
return
}
+
// file does not exist
// write out config file
err = self.Save()
@@ -97,6 +104,7 @@ func NewConfig(path string, contract common.Address, prvKey *ecdsa.PrivateKey, n
}
return
}
+
// file exists, deserialise
err = json.Unmarshal(data, self)
if err != nil {
@@ -109,6 +117,12 @@ func NewConfig(path string, contract common.Address, prvKey *ecdsa.PrivateKey, n
if 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 {
+ self.NetworkId = networkId
+ }
+
self.Swap.SetKey(prvKey)
if (self.EnsRoot == common.Address{}) {