mirror of
https://github.com/ethereum/go-ethereum.git
synced 2026-03-06 03:15:03 +00:00
p2p/server: allow setting MaxPeers dynamically
Signed-off-by: Csaba Kiraly <csaba.kiraly@gmail.com>
This commit is contained in:
parent
2619478ae9
commit
5046ea5626
2 changed files with 11 additions and 0 deletions
|
|
@ -185,6 +185,10 @@ func newDialScheduler(config dialConfig, it enode.Iterator, setupFunc dialSetupF
|
|||
return d
|
||||
}
|
||||
|
||||
func (d *dialScheduler) setMaxDialPeers(maxDialPeers int) {
|
||||
d.maxDialPeers = maxDialPeers
|
||||
}
|
||||
|
||||
// stop shuts down the dialer, canceling all current dial tasks.
|
||||
func (d *dialScheduler) stop() {
|
||||
d.cancel()
|
||||
|
|
|
|||
|
|
@ -420,6 +420,13 @@ func (srv *Server) Start() (err error) {
|
|||
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 {
|
||||
// Create the devp2p handshake.
|
||||
pubkey := crypto.FromECDSAPub(&srv.PrivateKey.PublicKey)
|
||||
|
|
|
|||
Loading…
Reference in a new issue