From 2ef669bcc4cdac18bbc089ece2c0df0154624b01 Mon Sep 17 00:00:00 2001 From: zelig Date: Mon, 18 Jul 2016 04:29:53 +0200 Subject: [PATCH] swarm/api: add default ENS tld registrar deployed on the toynet --- swarm/api/config.go | 14 ++++++++++++-- swarm/api/config_test.go | 2 +- swarm/swarm.go | 2 +- 3 files changed, 14 insertions(+), 4 deletions(-) diff --git a/swarm/api/config.go b/swarm/api/config.go index e9d4c87a8e..0af2e6c79d 100644 --- a/swarm/api/config.go +++ b/swarm/api/config.go @@ -8,17 +8,22 @@ import ( "os" "path/filepath" + "github.com/ethereum/go-ethereum/common" + "github.com/ethereum/go-ethereum/crypto" "github.com/ethereum/go-ethereum/swarm/network" "github.com/ethereum/go-ethereum/swarm/services/swap" "github.com/ethereum/go-ethereum/swarm/storage" - "github.com/ethereum/go-ethereum/common" - "github.com/ethereum/go-ethereum/crypto" ) const ( port = "8500" ) +// by default ens root is north internal +var ( + toyNetEnsRoot = common.HexToAddress("0xd422f059c2ea8e423a55b043ba427f43bf50a139") +) + // separate bzz directories // allow several bzz nodes running in parallel type Config struct { @@ -61,6 +66,7 @@ func NewConfig(path string, contract common.Address, prvKey *ecdsa.PrivateKey) ( Swap: swap.DefaultSwapParams(contract, prvKey), PublicKey: pubkeyhex, BzzKey: keyhex, + EnsRoot: toyNetEnsRoot, } data, err = ioutil.ReadFile(confpath) if err != nil { @@ -89,6 +95,10 @@ func NewConfig(path string, contract common.Address, prvKey *ecdsa.PrivateKey) ( } self.Swap.SetKey(prvKey) + if (self.EnsRoot == common.Address{}) { + self.EnsRoot = toyNetEnsRoot + } + return } diff --git a/swarm/api/config_test.go b/swarm/api/config_test.go index 25927b25b9..f11ad53b13 100644 --- a/swarm/api/config_test.go +++ b/swarm/api/config_test.go @@ -67,7 +67,7 @@ var ( "Port": "8500", "PublicKey": "0x045f5cfd26692e48d0017d380349bcf50982488bc11b5145f3ddf88b24924299048450542d43527fbe29a5cb32f38d62755393ac002e6bfdd71b8d7ba725ecd7a3", "BzzKey": "0xe861964402c0b78e2d44098329b8545726f215afa737d803714a4338552fcb81", - "EnsRoot": "0x0000000000000000000000000000000000000000" + "EnsRoot": "0xd422f059c2ea8e423a55b043ba427f43bf50a139" }` ) diff --git a/swarm/swarm.go b/swarm/swarm.go index 19080411b2..87ef9be314 100644 --- a/swarm/swarm.go +++ b/swarm/swarm.go @@ -140,7 +140,7 @@ func NewSwarm(ctx *node.ServiceContext, config *api.Config, swapEnabled, syncEna transactOpts := bind.NewKeyedTransactor(self.privateKey) // backend := ethereum.ContractBackend() self.dns = ens.NewENS(transactOpts, config.EnsRoot, self.backend) - glog.V(logger.Debug).Infof("[BZZ] -> Swarm Domain Name Registrar @ address %v", config.EnsRoot) + glog.V(logger.Debug).Infof("[BZZ] -> Swarm Domain Name Registrar @ address %v", config.EnsRoot.Hex()) self.api = api.NewApi(self.dpa, self.dns) // Manifests for Smart Hosting