Browse Source

les: fix nodiscover option (#21906)

Felföldi Zsolt 5 years ago
parent
commit
a2795c8055
5 changed files with 9 additions and 9 deletions
  1. 3 1
      cmd/utils/flags.go
  2. 1 1
      eth/backend.go
  3. 2 3
      eth/discovery.go
  4. 1 1
      les/client.go
  5. 2 3
      les/enr_entry.go

+ 3 - 1
cmd/utils/flags.go

@@ -1584,7 +1584,9 @@ func SetEthConfig(ctx *cli.Context, stack *node.Node, cfg *eth.Config) {
 	if ctx.GlobalIsSet(RPCGlobalTxFeeCapFlag.Name) {
 	if ctx.GlobalIsSet(RPCGlobalTxFeeCapFlag.Name) {
 		cfg.RPCTxFeeCap = ctx.GlobalFloat64(RPCGlobalTxFeeCapFlag.Name)
 		cfg.RPCTxFeeCap = ctx.GlobalFloat64(RPCGlobalTxFeeCapFlag.Name)
 	}
 	}
-	if ctx.GlobalIsSet(DNSDiscoveryFlag.Name) {
+	if ctx.GlobalIsSet(NoDiscoverFlag.Name) {
+		cfg.DiscoveryURLs = []string{}
+	} else if ctx.GlobalIsSet(DNSDiscoveryFlag.Name) {
 		urls := ctx.GlobalString(DNSDiscoveryFlag.Name)
 		urls := ctx.GlobalString(DNSDiscoveryFlag.Name)
 		if urls == "" {
 		if urls == "" {
 			cfg.DiscoveryURLs = []string{}
 			cfg.DiscoveryURLs = []string{}

+ 1 - 1
eth/backend.go

@@ -208,7 +208,7 @@ func New(stack *node.Node, config *Config) (*Ethereum, error) {
 	}
 	}
 	eth.APIBackend.gpo = gasprice.NewOracle(eth.APIBackend, gpoParams)
 	eth.APIBackend.gpo = gasprice.NewOracle(eth.APIBackend, gpoParams)
 
 
-	eth.dialCandidates, err = eth.setupDiscovery(&stack.Config().P2P)
+	eth.dialCandidates, err = eth.setupDiscovery()
 	if err != nil {
 	if err != nil {
 		return nil, err
 		return nil, err
 	}
 	}

+ 2 - 3
eth/discovery.go

@@ -19,7 +19,6 @@ package eth
 import (
 import (
 	"github.com/ethereum/go-ethereum/core"
 	"github.com/ethereum/go-ethereum/core"
 	"github.com/ethereum/go-ethereum/core/forkid"
 	"github.com/ethereum/go-ethereum/core/forkid"
-	"github.com/ethereum/go-ethereum/p2p"
 	"github.com/ethereum/go-ethereum/p2p/dnsdisc"
 	"github.com/ethereum/go-ethereum/p2p/dnsdisc"
 	"github.com/ethereum/go-ethereum/p2p/enode"
 	"github.com/ethereum/go-ethereum/p2p/enode"
 	"github.com/ethereum/go-ethereum/rlp"
 	"github.com/ethereum/go-ethereum/rlp"
@@ -65,8 +64,8 @@ func (eth *Ethereum) currentEthEntry() *ethEntry {
 }
 }
 
 
 // setupDiscovery creates the node discovery source for the eth protocol.
 // setupDiscovery creates the node discovery source for the eth protocol.
-func (eth *Ethereum) setupDiscovery(cfg *p2p.Config) (enode.Iterator, error) {
-	if cfg.NoDiscovery || len(eth.config.DiscoveryURLs) == 0 {
+func (eth *Ethereum) setupDiscovery() (enode.Iterator, error) {
+	if len(eth.config.DiscoveryURLs) == 0 {
 		return nil, nil
 		return nil, nil
 	}
 	}
 	client := dnsdisc.NewClient(dnsdisc.Config{})
 	client := dnsdisc.NewClient(dnsdisc.Config{})

+ 1 - 1
les/client.go

@@ -112,7 +112,7 @@ func New(stack *node.Node, config *eth.Config) (*LightEthereum, error) {
 	}
 	}
 	peers.subscribe((*vtSubscription)(leth.valueTracker))
 	peers.subscribe((*vtSubscription)(leth.valueTracker))
 
 
-	dnsdisc, err := leth.setupDiscovery(&stack.Config().P2P)
+	dnsdisc, err := leth.setupDiscovery()
 	if err != nil {
 	if err != nil {
 		return nil, err
 		return nil, err
 	}
 	}

+ 2 - 3
les/enr_entry.go

@@ -17,7 +17,6 @@
 package les
 package les
 
 
 import (
 import (
-	"github.com/ethereum/go-ethereum/p2p"
 	"github.com/ethereum/go-ethereum/p2p/dnsdisc"
 	"github.com/ethereum/go-ethereum/p2p/dnsdisc"
 	"github.com/ethereum/go-ethereum/p2p/enode"
 	"github.com/ethereum/go-ethereum/p2p/enode"
 	"github.com/ethereum/go-ethereum/rlp"
 	"github.com/ethereum/go-ethereum/rlp"
@@ -35,8 +34,8 @@ func (e lesEntry) ENRKey() string {
 }
 }
 
 
 // setupDiscovery creates the node discovery source for the eth protocol.
 // setupDiscovery creates the node discovery source for the eth protocol.
-func (eth *LightEthereum) setupDiscovery(cfg *p2p.Config) (enode.Iterator, error) {
-	if cfg.NoDiscovery || len(eth.config.DiscoveryURLs) == 0 {
+func (eth *LightEthereum) setupDiscovery() (enode.Iterator, error) {
+	if len(eth.config.DiscoveryURLs) == 0 {
 		return nil, nil
 		return nil, nil
 	}
 	}
 	client := dnsdisc.NewClient(dnsdisc.Config{})
 	client := dnsdisc.NewClient(dnsdisc.Config{})