server: Cap max outbound in connmgr cfg at max peers

This commit is contained in:
Javed Khan 2016-11-01 01:39:29 +05:30 committed by Dave Collins
parent 6951d8e235
commit d1c39edee8

View file

@ -2440,9 +2440,13 @@ func newServer(listenAddrs []string, db database.DB, chainParams *chaincfg.Param
} }
// Create a connection manager. // Create a connection manager.
maxOutbound := defaultMaxOutbound
if cfg.MaxPeers < maxOutbound {
maxOutbound = cfg.MaxPeers
}
cmgr, err := connmgr.New(&connmgr.Config{ cmgr, err := connmgr.New(&connmgr.Config{
RetryDuration: connectionRetryInterval, RetryDuration: connectionRetryInterval,
MaxOutbound: defaultMaxOutbound, MaxOutbound: uint32(maxOutbound),
Dial: btcdDial, Dial: btcdDial,
OnConnection: s.outboundPeerConnected, OnConnection: s.outboundPeerConnected,
GetNewAddress: newAddressFunc, GetNewAddress: newAddressFunc,