mirror of
https://github.com/ethereum/go-ethereum.git
synced 2026-07-27 15:16:43 +00:00
p2p: use discovery by default
This makes the zero Config slightly more useful. It also fixes package node tests because Node detects reuse of the datadir through the NodeDatabase.
This commit is contained in:
parent
075642f105
commit
0df01af538
5 changed files with 11 additions and 16 deletions
|
|
@ -54,13 +54,10 @@ var (
|
|||
)
|
||||
|
||||
var defaultNodeConfig = node.Config{
|
||||
Name: clientIdentifier,
|
||||
Version: params.VersionWithCommit(gitCommit),
|
||||
DataDir: node.DefaultDataDir(),
|
||||
P2P: p2p.Config{
|
||||
MaxPeers: 25,
|
||||
Discovery: true,
|
||||
},
|
||||
Name: clientIdentifier,
|
||||
Version: params.VersionWithCommit(gitCommit),
|
||||
DataDir: node.DefaultDataDir(),
|
||||
P2P: p2p.Config{MaxPeers: 25},
|
||||
HTTPModules: []string{"eth", "net", "web3"},
|
||||
WSModules: []string{"eth", "net", "web3"},
|
||||
}
|
||||
|
|
|
|||
|
|
@ -695,7 +695,7 @@ func SetP2PConfig(ctx *cli.Context, cfg *p2p.Config) {
|
|||
cfg.MaxPendingPeers = ctx.GlobalInt(MaxPendingPeersFlag.Name)
|
||||
}
|
||||
if ctx.GlobalIsSet(NoDiscoverFlag.Name) || ctx.GlobalBool(LightModeFlag.Name) {
|
||||
cfg.Discovery = false
|
||||
cfg.NoDiscovery = true
|
||||
}
|
||||
|
||||
// if we're running a light client or server, force enable the v5 peer discovery
|
||||
|
|
@ -720,7 +720,7 @@ func SetP2PConfig(ctx *cli.Context, cfg *p2p.Config) {
|
|||
// --dev mode can't use p2p networking.
|
||||
cfg.MaxPeers = 0
|
||||
cfg.ListenAddr = ":0"
|
||||
cfg.Discovery = false
|
||||
cfg.NoDiscovery = true
|
||||
cfg.DiscoveryV5 = false
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -257,7 +257,6 @@ func initialize() {
|
|||
Config: p2p.Config{
|
||||
PrivateKey: nodeid,
|
||||
MaxPeers: maxPeers,
|
||||
Discovery: true,
|
||||
Name: common.MakeName("wnode", "5.0"),
|
||||
Protocols: shh.Protocols(),
|
||||
ListenAddr: *argIP,
|
||||
|
|
|
|||
|
|
@ -115,7 +115,6 @@ func NewNode(datadir string, config *NodeConfig) (stack *Node, _ error) {
|
|||
DataDir: datadir,
|
||||
KeyStoreDir: filepath.Join(datadir, "keystore"), // Mobile should never use internal keystores!
|
||||
P2P: p2p.Config{
|
||||
Discovery: true,
|
||||
DiscoveryV5: true,
|
||||
DiscoveryV5Addr: ":0",
|
||||
BootstrapNodesV5: config.BootstrapNodes.nodes,
|
||||
|
|
|
|||
|
|
@ -69,9 +69,9 @@ type Config struct {
|
|||
// Zero defaults to preset values.
|
||||
MaxPendingPeers int `toml:",omitempty"`
|
||||
|
||||
// Discovery specifies whether the peer discovery mechanism should be started
|
||||
// or not. Disabling is usually useful for protocol debugging (manual topology).
|
||||
Discovery bool
|
||||
// NoDiscowery can be used to disable the peer discovery mechanism.
|
||||
// Disabling is useful for protocol debugging (manual topology).
|
||||
NoDiscovery bool
|
||||
|
||||
// DiscoveryV5 specifies whether the the new topic-discovery based V5 discovery
|
||||
// protocol should be started or not.
|
||||
|
|
@ -370,7 +370,7 @@ func (srv *Server) Start() (err error) {
|
|||
srv.peerOpDone = make(chan struct{})
|
||||
|
||||
// node table
|
||||
if srv.Discovery {
|
||||
if !srv.NoDiscovery {
|
||||
ntab, err := discover.ListenUDP(srv.PrivateKey, srv.ListenAddr, srv.NAT, srv.NodeDatabase, srv.NetRestrict)
|
||||
if err != nil {
|
||||
return err
|
||||
|
|
@ -393,7 +393,7 @@ func (srv *Server) Start() (err error) {
|
|||
}
|
||||
|
||||
dynPeers := (srv.MaxPeers + 1) / 2
|
||||
if !srv.Discovery {
|
||||
if srv.NoDiscovery {
|
||||
dynPeers = 0
|
||||
}
|
||||
dialer := newDialState(srv.StaticNodes, srv.BootstrapNodes, srv.ntab, dynPeers, srv.NetRestrict)
|
||||
|
|
|
|||
Loading…
Reference in a new issue