mirror of
https://github.com/nspcc-dev/neo-go.git
synced 2025-01-03 19:22:49 +00:00
Merge pull request #3727 from nspcc-dev/network-optimaln
network: optimize optimalN for small networks
This commit is contained in:
commit
1aed0faeec
1 changed files with 2 additions and 2 deletions
|
@ -482,7 +482,7 @@ func (s *Server) run() {
|
|||
var (
|
||||
netSize = s.discovery.NetworkSize()
|
||||
// "Optimal" number of peers.
|
||||
optimalN = s.discovery.GetFanOut() * 2
|
||||
optimalN = min(s.discovery.GetFanOut()*2, netSize-1)
|
||||
// Real number of peers.
|
||||
peerN = s.HandshakedPeersCount()
|
||||
// Timeout value for the next peerTimer, long one by default.
|
||||
|
@ -494,7 +494,7 @@ func (s *Server) run() {
|
|||
s.discovery.RequestRemote(s.AttemptConnPeers)
|
||||
// Check/retry new connections soon.
|
||||
peerT = s.ProtoTickInterval
|
||||
} else if s.MinPeers > 0 && loopCnt%s.MinPeers == 0 && optimalN > peerN && optimalN < s.MaxPeers && optimalN < netSize {
|
||||
} else if s.MinPeers > 0 && loopCnt%s.MinPeers == 0 && optimalN > peerN && optimalN < s.MaxPeers {
|
||||
// Having some number of peers, but probably can get some more, the network is big.
|
||||
// It also allows to start picking up new peers proactively, before we suddenly have <s.MinPeers of them.
|
||||
s.discovery.RequestRemote(min(s.AttemptConnPeers, optimalN-peerN))
|
||||
|
|
Loading…
Reference in a new issue