mirror of
https://github.com/tendermint/tendermint.git
synced 2026-09-20 06:54:41 +00:00
(cherry picked from commit 28d3239958)
Co-authored-by: Sam Kleinman <garen@tychoish.com>
This commit is contained in:
co-authored by
Sam Kleinman
parent
1975cdd750
commit
1b872d768b
@@ -498,6 +498,15 @@ func (m *PeerManager) HasMaxPeerCapacity() bool {
|
||||
return len(m.connected) >= int(m.options.MaxConnected)
|
||||
}
|
||||
|
||||
func (m *PeerManager) HasDialedMaxPeers() bool {
|
||||
m.mtx.Lock()
|
||||
defer m.mtx.Unlock()
|
||||
|
||||
stats := m.getConnectedInfo()
|
||||
|
||||
return stats.outgoing >= m.options.MaxOutgoingConnections
|
||||
}
|
||||
|
||||
// DialNext finds an appropriate peer address to dial, and marks it as dialing.
|
||||
// If no peer is found, or all connection slots are full, it blocks until one
|
||||
// becomes available. The caller must call Dialed() or DialFailed() for the
|
||||
|
||||
@@ -466,6 +466,11 @@ func (r *Router) dialSleep(ctx context.Context) {
|
||||
}
|
||||
|
||||
r.options.DialSleep(ctx)
|
||||
|
||||
if !r.peerManager.HasDialedMaxPeers() {
|
||||
r.peerManager.dialWaker.Wake()
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
// acceptPeers accepts inbound connections from peers on the given transport,
|
||||
|
||||
Reference in New Issue
Block a user