mirror of
https://github.com/ethereum/go-ethereum.git
synced 2026-08-20 10:52:25 +00:00
eth: remove DNS URLs
This commit is contained in:
parent
36d754cbc6
commit
c2db1d8a12
3 changed files with 25 additions and 24 deletions
|
|
@ -95,9 +95,9 @@ type Config struct {
|
|||
NetworkId uint64 // Network ID to use for selecting peers to connect to
|
||||
SyncMode downloader.SyncMode
|
||||
|
||||
// Discovery options
|
||||
DisableDNSDiscovery bool
|
||||
DiscoveryURLs []string
|
||||
// This can be set to list of enrtree:// URLs which will be queried for
|
||||
// for nodes to connect to.
|
||||
DiscoveryURLs []string
|
||||
|
||||
NoPruning bool // Whether to disable pruning and flush everything to disk
|
||||
NoPrefetch bool // Whether to disable prefetching and only load state on demand
|
||||
|
|
@ -160,8 +160,8 @@ type Config struct {
|
|||
CheckpointOracle *params.CheckpointOracleConfig `toml:",omitempty"`
|
||||
|
||||
// Istanbul block override (TODO: remove after the fork)
|
||||
OverrideIstanbul *big.Int
|
||||
OverrideIstanbul *big.Int `toml:",omitempty"`
|
||||
|
||||
// MuirGlacier block override (TODO: remove after the fork)
|
||||
OverrideMuirGlacier *big.Int
|
||||
OverrideMuirGlacier *big.Int `toml:",omitempty"`
|
||||
}
|
||||
|
|
|
|||
|
|
@ -17,23 +17,14 @@
|
|||
package eth
|
||||
|
||||
import (
|
||||
"github.com/ethereum/go-ethereum/common"
|
||||
"github.com/ethereum/go-ethereum/core"
|
||||
"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/enode"
|
||||
"github.com/ethereum/go-ethereum/params"
|
||||
"github.com/ethereum/go-ethereum/rlp"
|
||||
)
|
||||
|
||||
var knownDNSNetworks = map[common.Hash]string{
|
||||
params.MainnetGenesisHash: "enrtree://AMBMWDM3J6UY3M32TMMROUNLX6Y3YTLVC3DC6HN2AVG5NHNSAXDW6@all.mainnet.nodes.ethflare.xyz",
|
||||
params.TestnetGenesisHash: "enrtree://AMBMWDM3J6UY3M32TMMROUNLX6Y3YTLVC3DC6HN2AVG5NHNSAXDW6@all.ropsten.nodes.ethflare.xyz",
|
||||
params.RinkebyGenesisHash: "enrtree://AMBMWDM3J6UY3M32TMMROUNLX6Y3YTLVC3DC6HN2AVG5NHNSAXDW6@all.rinkeby.nodes.ethflare.xyz",
|
||||
params.GoerliGenesisHash: "enrtree://AMBMWDM3J6UY3M32TMMROUNLX6Y3YTLVC3DC6HN2AVG5NHNSAXDW6@all.goerli.nodes.ethflare.xyz",
|
||||
}
|
||||
|
||||
// ethEntry is the "eth" ENR entry which advertises eth protocol
|
||||
// on the discovery network.
|
||||
type ethEntry struct {
|
||||
|
|
@ -74,17 +65,9 @@ func (eth *Ethereum) currentEthEntry() *ethEntry {
|
|||
|
||||
// setupDiscovery creates the node discovery source for the eth protocol.
|
||||
func (eth *Ethereum) setupDiscovery(cfg *p2p.Config) (enode.Iterator, error) {
|
||||
if cfg.NoDiscovery || eth.config.DisableDNSDiscovery {
|
||||
if cfg.NoDiscovery || len(eth.config.DiscoveryURLs) == 0 {
|
||||
return nil, nil
|
||||
}
|
||||
known := knownDNSNetworks[eth.blockchain.Genesis().Hash()]
|
||||
urls := eth.config.DiscoveryURLs
|
||||
if len(urls) == 0 {
|
||||
if known == "" {
|
||||
return nil, nil
|
||||
}
|
||||
urls = []string{known}
|
||||
}
|
||||
client := dnsdisc.NewClient(dnsdisc.Config{})
|
||||
return client.NewIterator(urls...)
|
||||
return client.NewIterator(eth.config.DiscoveryURLs...)
|
||||
}
|
||||
|
|
|
|||
|
|
@ -21,6 +21,7 @@ func (c Config) MarshalTOML() (interface{}, error) {
|
|||
Genesis *core.Genesis `toml:",omitempty"`
|
||||
NetworkId uint64
|
||||
SyncMode downloader.SyncMode
|
||||
DiscoveryURLs []string
|
||||
NoPruning bool
|
||||
NoPrefetch bool
|
||||
Whitelist map[uint64]common.Hash `toml:"-"`
|
||||
|
|
@ -49,11 +50,14 @@ func (c Config) MarshalTOML() (interface{}, error) {
|
|||
RPCGasCap *big.Int `toml:",omitempty"`
|
||||
Checkpoint *params.TrustedCheckpoint `toml:",omitempty"`
|
||||
CheckpointOracle *params.CheckpointOracleConfig `toml:",omitempty"`
|
||||
OverrideIstanbul *big.Int `toml:",omitempty"`
|
||||
OverrideMuirGlacier *big.Int `toml:",omitempty"`
|
||||
}
|
||||
var enc Config
|
||||
enc.Genesis = c.Genesis
|
||||
enc.NetworkId = c.NetworkId
|
||||
enc.SyncMode = c.SyncMode
|
||||
enc.DiscoveryURLs = c.DiscoveryURLs
|
||||
enc.NoPruning = c.NoPruning
|
||||
enc.NoPrefetch = c.NoPrefetch
|
||||
enc.Whitelist = c.Whitelist
|
||||
|
|
@ -82,6 +86,8 @@ func (c Config) MarshalTOML() (interface{}, error) {
|
|||
enc.RPCGasCap = c.RPCGasCap
|
||||
enc.Checkpoint = c.Checkpoint
|
||||
enc.CheckpointOracle = c.CheckpointOracle
|
||||
enc.OverrideIstanbul = c.OverrideIstanbul
|
||||
enc.OverrideMuirGlacier = c.OverrideMuirGlacier
|
||||
return &enc, nil
|
||||
}
|
||||
|
||||
|
|
@ -91,6 +97,7 @@ func (c *Config) UnmarshalTOML(unmarshal func(interface{}) error) error {
|
|||
Genesis *core.Genesis `toml:",omitempty"`
|
||||
NetworkId *uint64
|
||||
SyncMode *downloader.SyncMode
|
||||
DiscoveryURLs []string
|
||||
NoPruning *bool
|
||||
NoPrefetch *bool
|
||||
Whitelist map[uint64]common.Hash `toml:"-"`
|
||||
|
|
@ -119,6 +126,8 @@ func (c *Config) UnmarshalTOML(unmarshal func(interface{}) error) error {
|
|||
RPCGasCap *big.Int `toml:",omitempty"`
|
||||
Checkpoint *params.TrustedCheckpoint `toml:",omitempty"`
|
||||
CheckpointOracle *params.CheckpointOracleConfig `toml:",omitempty"`
|
||||
OverrideIstanbul *big.Int `toml:",omitempty"`
|
||||
OverrideMuirGlacier *big.Int `toml:",omitempty"`
|
||||
}
|
||||
var dec Config
|
||||
if err := unmarshal(&dec); err != nil {
|
||||
|
|
@ -133,6 +142,9 @@ func (c *Config) UnmarshalTOML(unmarshal func(interface{}) error) error {
|
|||
if dec.SyncMode != nil {
|
||||
c.SyncMode = *dec.SyncMode
|
||||
}
|
||||
if dec.DiscoveryURLs != nil {
|
||||
c.DiscoveryURLs = dec.DiscoveryURLs
|
||||
}
|
||||
if dec.NoPruning != nil {
|
||||
c.NoPruning = *dec.NoPruning
|
||||
}
|
||||
|
|
@ -217,5 +229,11 @@ func (c *Config) UnmarshalTOML(unmarshal func(interface{}) error) error {
|
|||
if dec.CheckpointOracle != nil {
|
||||
c.CheckpointOracle = dec.CheckpointOracle
|
||||
}
|
||||
if dec.OverrideIstanbul != nil {
|
||||
c.OverrideIstanbul = dec.OverrideIstanbul
|
||||
}
|
||||
if dec.OverrideMuirGlacier != nil {
|
||||
c.OverrideMuirGlacier = dec.OverrideMuirGlacier
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue