cmd/swarm: Support using Mainnet for resolving ENS names

Signed-off-by: Lewis Marshall <lewis@lmars.net>
This commit is contained in:
Lewis Marshall
2017-06-18 00:25:39 +02:00
parent feb2932706
commit f3359d5e58
4 changed files with 109 additions and 18 deletions

View File

@ -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
}