diff options
author | nolash <dev@holbrook.no> | 2017-01-27 03:33:39 +0800 |
---|---|---|
committer | nolash <dev@holbrook.no> | 2017-01-27 15:18:13 +0800 |
commit | 7669c5b5ec5b18e96a0714d667468247a3da3d68 (patch) | |
tree | 21d05653609b54e22dea26c946215726ce86a93d /swarm/api/config.go | |
parent | 82aa5b1de69331a43f5050717d593aa97eda1ef5 (diff) | |
download | go-tangerine-7669c5b5ec5b18e96a0714d667468247a3da3d68.tar go-tangerine-7669c5b5ec5b18e96a0714d667468247a3da3d68.tar.gz go-tangerine-7669c5b5ec5b18e96a0714d667468247a3da3d68.tar.bz2 go-tangerine-7669c5b5ec5b18e96a0714d667468247a3da3d68.tar.lz go-tangerine-7669c5b5ec5b18e96a0714d667468247a3da3d68.tar.xz go-tangerine-7669c5b5ec5b18e96a0714d667468247a3da3d68.tar.zst go-tangerine-7669c5b5ec5b18e96a0714d667468247a3da3d68.zip |
cmd/swarm, swarm/api: bzzr improve + networkid prio
fixes #3444
fixes #3494
networkid override
Added comments to explain why test against 0 appears twice
* Command line overrides saved config, saved config overrides system default
---
fixes #3476
bzzr get with path
Finally a hopefully clean commit for this PR
Added check for empty path to avoid SIGSEGV in path parser and resolver
Added requested tests for empty path and non-existing manifest.
However signature for StartHTTPServer had changed.
Now it's hacked as so:
StartHttpServer(api.API, &Server{Addr: "127.0.0.1:8504", CorsString: ""})
* Parse url before resolve when path and ENS is supplied, example
* swarm/api/http proxy server test for retrieval of subpath through get
* Removed nil entry assignment on subtrie leaf in recursive key retrieval
* Cleaned up path-or-no-path condition in proxy server get handler
* swarm: processed with gofmt refers to lash/go-ethereum@90daa7a
* swarm: Added public access method Parse alias to parse
* swarm: processed with gofmt References nolash/go-ethereum@2ec3fd7
* Rename parse to Parse, removed alias
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{}) { |