Skip to content

Commit a2795c8

Browse files
authored
les: fix nodiscover option (#21906)
1 parent e7db1db commit a2795c8

5 files changed

Lines changed: 9 additions & 9 deletions

File tree

‎cmd/utils/flags.go‎

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1584,7 +1584,9 @@ func SetEthConfig(ctx *cli.Context, stack *node.Node, cfg *eth.Config) {
15841584
if ctx.GlobalIsSet(RPCGlobalTxFeeCapFlag.Name) {
15851585
cfg.RPCTxFeeCap = ctx.GlobalFloat64(RPCGlobalTxFeeCapFlag.Name)
15861586
}
1587-
if ctx.GlobalIsSet(DNSDiscoveryFlag.Name) {
1587+
if ctx.GlobalIsSet(NoDiscoverFlag.Name) {
1588+
cfg.DiscoveryURLs = []string{}
1589+
} else if ctx.GlobalIsSet(DNSDiscoveryFlag.Name) {
15881590
urls := ctx.GlobalString(DNSDiscoveryFlag.Name)
15891591
if urls == "" {
15901592
cfg.DiscoveryURLs = []string{}

‎eth/backend.go‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -208,7 +208,7 @@ func New(stack *node.Node, config *Config) (*Ethereum, error) {
208208
}
209209
eth.APIBackend.gpo = gasprice.NewOracle(eth.APIBackend, gpoParams)
210210

211-
eth.dialCandidates, err = eth.setupDiscovery(&stack.Config().P2P)
211+
eth.dialCandidates, err = eth.setupDiscovery()
212212
if err != nil {
213213
return nil, err
214214
}

‎eth/discovery.go‎

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,6 @@ package eth
1919
import (
2020
"github.com/ethereum/go-ethereum/core"
2121
"github.com/ethereum/go-ethereum/core/forkid"
22-
"github.com/ethereum/go-ethereum/p2p"
2322
"github.com/ethereum/go-ethereum/p2p/dnsdisc"
2423
"github.com/ethereum/go-ethereum/p2p/enode"
2524
"github.com/ethereum/go-ethereum/rlp"
@@ -65,8 +64,8 @@ func (eth *Ethereum) currentEthEntry() *ethEntry {
6564
}
6665

6766
// setupDiscovery creates the node discovery source for the eth protocol.
68-
func (eth *Ethereum) setupDiscovery(cfg *p2p.Config) (enode.Iterator, error) {
69-
if cfg.NoDiscovery || len(eth.config.DiscoveryURLs) == 0 {
67+
func (eth *Ethereum) setupDiscovery() (enode.Iterator, error) {
68+
if len(eth.config.DiscoveryURLs) == 0 {
7069
return nil, nil
7170
}
7271
client := dnsdisc.NewClient(dnsdisc.Config{})

‎les/client.go‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -112,7 +112,7 @@ func New(stack *node.Node, config *eth.Config) (*LightEthereum, error) {
112112
}
113113
peers.subscribe((*vtSubscription)(leth.valueTracker))
114114

115-
dnsdisc, err := leth.setupDiscovery(&stack.Config().P2P)
115+
dnsdisc, err := leth.setupDiscovery()
116116
if err != nil {
117117
return nil, err
118118
}

‎les/enr_entry.go‎

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,6 @@
1717
package les
1818

1919
import (
20-
"github.com/ethereum/go-ethereum/p2p"
2120
"github.com/ethereum/go-ethereum/p2p/dnsdisc"
2221
"github.com/ethereum/go-ethereum/p2p/enode"
2322
"github.com/ethereum/go-ethereum/rlp"
@@ -35,8 +34,8 @@ func (e lesEntry) ENRKey() string {
3534
}
3635

3736
// setupDiscovery creates the node discovery source for the eth protocol.
38-
func (eth *LightEthereum) setupDiscovery(cfg *p2p.Config) (enode.Iterator, error) {
39-
if cfg.NoDiscovery || len(eth.config.DiscoveryURLs) == 0 {
37+
func (eth *LightEthereum) setupDiscovery() (enode.Iterator, error) {
38+
if len(eth.config.DiscoveryURLs) == 0 {
4039
return nil, nil
4140
}
4241
client := dnsdisc.NewClient(dnsdisc.Config{})

0 commit comments

Comments
 (0)