mirror of
https://github.com/tendermint/tendermint.git
synced 2026-01-10 06:57:24 +00:00
p2p: address audit issues with the peer manager (#6603)
This commit is contained in:
@@ -434,11 +434,13 @@ func (m *PeerManager) Add(address NodeAddress) (bool, error) {
|
||||
|
||||
// PeerRatio returns the ratio of peer addresses stored to the maximum size.
|
||||
func (m *PeerManager) PeerRatio() float64 {
|
||||
m.mtx.Lock()
|
||||
defer m.mtx.Unlock()
|
||||
|
||||
if m.options.MaxPeers == 0 {
|
||||
return 0
|
||||
}
|
||||
m.mtx.Lock()
|
||||
defer m.mtx.Unlock()
|
||||
|
||||
return float64(m.store.Size()) / float64(m.options.MaxPeers)
|
||||
}
|
||||
|
||||
@@ -551,9 +553,10 @@ func (m *PeerManager) DialFailed(address NodeAddress) error {
|
||||
case <-m.closeCh:
|
||||
}
|
||||
}()
|
||||
} else {
|
||||
m.dialWaker.Wake()
|
||||
}
|
||||
|
||||
m.dialWaker.Wake()
|
||||
return nil
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user