aboutsummaryrefslogtreecommitdiffstats
path: root/swarm
diff options
context:
space:
mode:
authorLewis Marshall <lewis@lmars.net>2017-06-18 06:25:39 +0800
committerLewis Marshall <lewis@lmars.net>2017-06-26 18:51:33 +0800
commitf3359d5e585eef09648c7a06a6d3911704f61e73 (patch)
tree3f36e858799621da5df214f428e6dda5be27a173 /swarm
parentfeb29327066d6076d1802cdc1492d43a39cec276 (diff)
downloaddexon-f3359d5e585eef09648c7a06a6d3911704f61e73.tar
dexon-f3359d5e585eef09648c7a06a6d3911704f61e73.tar.gz
dexon-f3359d5e585eef09648c7a06a6d3911704f61e73.tar.bz2
dexon-f3359d5e585eef09648c7a06a6d3911704f61e73.tar.lz
dexon-f3359d5e585eef09648c7a06a6d3911704f61e73.tar.xz
dexon-f3359d5e585eef09648c7a06a6d3911704f61e73.tar.zst
dexon-f3359d5e585eef09648c7a06a6d3911704f61e73.zip
cmd/swarm: Support using Mainnet for resolving ENS names
Signed-off-by: Lewis Marshall <lewis@lmars.net>
Diffstat (limited to 'swarm')
-rw-r--r--swarm/api/config.go9
-rw-r--r--swarm/swarm.go8
2 files changed, 7 insertions, 10 deletions
diff --git a/swarm/api/config.go b/swarm/api/config.go
index 647c153ed..d8d25b1c8 100644
--- a/swarm/api/config.go
+++ b/swarm/api/config.go
@@ -25,6 +25,7 @@ import (
"path/filepath"
"github.com/ethereum/go-ethereum/common"
+ "github.com/ethereum/go-ethereum/contracts/ens"
"github.com/ethereum/go-ethereum/crypto"
"github.com/ethereum/go-ethereum/swarm/network"
"github.com/ethereum/go-ethereum/swarm/services/swap"
@@ -36,10 +37,6 @@ const (
DefaultHTTPPort = "8500"
)
-var (
- ensRootAddress = common.HexToAddress("0x112234455c3a32fd11230c42e7bccd4a84e02010")
-)
-
// separate bzz directories
// allow several bzz nodes running in parallel
type Config struct {
@@ -84,7 +81,7 @@ func NewConfig(path string, contract common.Address, prvKey *ecdsa.PrivateKey, n
Swap: swap.DefaultSwapParams(contract, prvKey),
PublicKey: pubkeyhex,
BzzKey: keyhex,
- EnsRoot: ensRootAddress,
+ EnsRoot: ens.TestNetAddress,
NetworkId: networkId,
}
data, err = ioutil.ReadFile(confpath)
@@ -129,7 +126,7 @@ func NewConfig(path string, contract common.Address, prvKey *ecdsa.PrivateKey, n
self.Swap.SetKey(prvKey)
if (self.EnsRoot == common.Address{}) {
- self.EnsRoot = ensRootAddress
+ self.EnsRoot = ens.TestNetAddress
}
return
diff --git a/swarm/swarm.go b/swarm/swarm.go
index 4f93a30b7..830490843 100644
--- a/swarm/swarm.go
+++ b/swarm/swarm.go
@@ -76,7 +76,7 @@ func (self *Swarm) API() *SwarmAPI {
// creates a new swarm service instance
// implements node.Service
-func NewSwarm(ctx *node.ServiceContext, backend chequebook.Backend, config *api.Config, swapEnabled, syncEnabled bool, cors string) (self *Swarm, err error) {
+func NewSwarm(ctx *node.ServiceContext, backend chequebook.Backend, ensClient *ethclient.Client, config *api.Config, swapEnabled, syncEnabled bool, cors string) (self *Swarm, err error) {
if bytes.Equal(common.FromHex(config.PublicKey), storage.ZeroKey) {
return nil, fmt.Errorf("empty public key")
}
@@ -136,10 +136,10 @@ func NewSwarm(ctx *node.ServiceContext, backend chequebook.Backend, config *api.
// set up high level api
transactOpts := bind.NewKeyedTransactor(self.privateKey)
- if backend == (*ethclient.Client)(nil) {
- log.Warn("No ENS, please specify non-empty --ethapi to use domain name resolution")
+ if ensClient == nil {
+ log.Warn("No ENS, please specify non-empty --ens-api to use domain name resolution")
} else {
- self.dns, err = ens.NewENS(transactOpts, config.EnsRoot, self.backend)
+ self.dns, err = ens.NewENS(transactOpts, config.EnsRoot, ensClient)
if err != nil {
return nil, err
}