diff options
author | Péter Szilágyi <peterke@gmail.com> | 2017-01-30 22:36:30 +0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2017-01-30 22:36:30 +0800 |
commit | 1c140f73820e2a915dcc61eccaeca7ea359cf07b (patch) | |
tree | ed3c5330a14344d6c716d19306154f17cd1efcbc /swarm/api/config.go | |
parent | f3c368ca736ed2884943cf87b029d305b7fc7c61 (diff) | |
parent | e5a93bf99abc0db5efbfab17feb61cfaef5a19ed (diff) | |
download | dexon-1c140f73820e2a915dcc61eccaeca7ea359cf07b.tar dexon-1c140f73820e2a915dcc61eccaeca7ea359cf07b.tar.gz dexon-1c140f73820e2a915dcc61eccaeca7ea359cf07b.tar.bz2 dexon-1c140f73820e2a915dcc61eccaeca7ea359cf07b.tar.lz dexon-1c140f73820e2a915dcc61eccaeca7ea359cf07b.tar.xz dexon-1c140f73820e2a915dcc61eccaeca7ea359cf07b.tar.zst dexon-1c140f73820e2a915dcc61eccaeca7ea359cf07b.zip |
Merge pull request #3615 from nolash/bzzpathfix_real5
cmd/swarm, swarm/api: bzzr improve + networkid prio
Diffstat (limited to 'swarm/api/config.go')
-rw-r--r-- | swarm/api/config.go | 14 |
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{}) { |