swarm/api: better name resolver handling (#3754)

Fixes #3608
This commit is contained in:
holisticode
2017-04-13 04:06:19 -05:00
committed by Felix Lange
parent d5d910e8b6
commit 409b61fe3c
4 changed files with 53 additions and 16 deletions

View File

@ -27,6 +27,7 @@ import (
"github.com/ethereum/go-ethereum/contracts/chequebook"
"github.com/ethereum/go-ethereum/contracts/ens"
"github.com/ethereum/go-ethereum/crypto"
"github.com/ethereum/go-ethereum/ethclient"
"github.com/ethereum/go-ethereum/log"
"github.com/ethereum/go-ethereum/node"
"github.com/ethereum/go-ethereum/p2p"
@ -134,9 +135,13 @@ func NewSwarm(ctx *node.ServiceContext, backend chequebook.Backend, config *api.
// set up high level api
transactOpts := bind.NewKeyedTransactor(self.privateKey)
self.dns, err = ens.NewENS(transactOpts, config.EnsRoot, self.backend)
if err != nil {
return nil, err
if backend == (*ethclient.Client)(nil) {
log.Warn("No ENS, please specify non-empty --ethapi to use domain name resolution")
} else {
self.dns, err = ens.NewENS(transactOpts, config.EnsRoot, self.backend)
if err != nil {
return nil, err
}
}
log.Debug(fmt.Sprintf("-> Swarm Domain Name Registrar @ address %v", config.EnsRoot.Hex()))