mirror of
https://github.com/tendermint/tendermint.git
synced 2026-08-17 04:36:11 +00:00
p2p: wake dialing thread after sleep (#8803)
This commit is contained in:
@@ -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