mirror of
https://github.com/ethereum/go-ethereum.git
synced 2026-05-24 08:49:29 +00:00
Merge e66f3c4c26 into 12eabbd76d
This commit is contained in:
commit
13623bcb6d
5 changed files with 26 additions and 0 deletions
|
|
@ -465,6 +465,12 @@ func (s *Ethereum) Start() error {
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (s *Ethereum) setMaxPeers(max int) {
|
||||||
|
s.p2pServer.SetMaxPeers(max)
|
||||||
|
s.handler.SetMaxPeers(max)
|
||||||
|
s.dropper.SetMaxPeers(s.p2pServer.MaxDialedConns(), s.p2pServer.MaxInboundConns())
|
||||||
|
}
|
||||||
|
|
||||||
func (s *Ethereum) newChainView(head *types.Header) *filtermaps.ChainView {
|
func (s *Ethereum) newChainView(head *types.Header) *filtermaps.ChainView {
|
||||||
if head == nil {
|
if head == nil {
|
||||||
return nil
|
return nil
|
||||||
|
|
|
||||||
|
|
@ -88,6 +88,11 @@ func newDropper(maxDialPeers, maxInboundPeers int) *dropper {
|
||||||
return cm
|
return cm
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (cm *dropper) SetMaxPeers(maxDialPeers, maxInboundPeers int) {
|
||||||
|
cm.maxDialPeers = maxDialPeers
|
||||||
|
cm.maxInboundPeers = maxInboundPeers
|
||||||
|
}
|
||||||
|
|
||||||
// Start the dropper.
|
// Start the dropper.
|
||||||
func (cm *dropper) Start(srv *p2p.Server, syncingFunc getSyncingFunc) {
|
func (cm *dropper) Start(srv *p2p.Server, syncingFunc getSyncingFunc) {
|
||||||
cm.peersFunc = srv.Peers
|
cm.peersFunc = srv.Peers
|
||||||
|
|
|
||||||
|
|
@ -402,6 +402,10 @@ func (h *handler) unregisterPeer(id string) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (h *handler) SetMaxPeers(maxPeers int) {
|
||||||
|
h.maxPeers = maxPeers
|
||||||
|
}
|
||||||
|
|
||||||
func (h *handler) Start(maxPeers int) {
|
func (h *handler) Start(maxPeers int) {
|
||||||
h.maxPeers = maxPeers
|
h.maxPeers = maxPeers
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -195,6 +195,10 @@ func newDialScheduler(config dialConfig, it enode.Iterator, setupFunc dialSetupF
|
||||||
return d
|
return d
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (d *dialScheduler) setMaxDialPeers(maxDialPeers int) {
|
||||||
|
d.maxDialPeers = maxDialPeers
|
||||||
|
}
|
||||||
|
|
||||||
// stop shuts down the dialer, canceling all current dial tasks.
|
// stop shuts down the dialer, canceling all current dial tasks.
|
||||||
func (d *dialScheduler) stop() {
|
func (d *dialScheduler) stop() {
|
||||||
d.cancel()
|
d.cancel()
|
||||||
|
|
|
||||||
|
|
@ -415,6 +415,13 @@ func (srv *Server) Start() (err error) {
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (srv *Server) SetMaxPeers(max int) {
|
||||||
|
srv.lock.Lock()
|
||||||
|
defer srv.lock.Unlock()
|
||||||
|
srv.MaxPeers = max
|
||||||
|
srv.dialsched.setMaxDialPeers(srv.MaxDialedConns())
|
||||||
|
}
|
||||||
|
|
||||||
func (srv *Server) setupLocalNode() error {
|
func (srv *Server) setupLocalNode() error {
|
||||||
// Create the devp2p handshake.
|
// Create the devp2p handshake.
|
||||||
pubkey := crypto.FromECDSAPub(&srv.PrivateKey.PublicKey)
|
pubkey := crypto.FromECDSAPub(&srv.PrivateKey.PublicKey)
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue