|
@ -434,11 +434,13 @@ func (m *PeerManager) Add(address NodeAddress) (bool, error) { |
|
|
|
|
|
|
|
|
// PeerRatio returns the ratio of peer addresses stored to the maximum size.
|
|
|
// PeerRatio returns the ratio of peer addresses stored to the maximum size.
|
|
|
func (m *PeerManager) PeerRatio() float64 { |
|
|
func (m *PeerManager) PeerRatio() float64 { |
|
|
|
|
|
m.mtx.Lock() |
|
|
|
|
|
defer m.mtx.Unlock() |
|
|
|
|
|
|
|
|
if m.options.MaxPeers == 0 { |
|
|
if m.options.MaxPeers == 0 { |
|
|
return 0 |
|
|
return 0 |
|
|
} |
|
|
} |
|
|
m.mtx.Lock() |
|
|
|
|
|
defer m.mtx.Unlock() |
|
|
|
|
|
|
|
|
|
|
|
return float64(m.store.Size()) / float64(m.options.MaxPeers) |
|
|
return float64(m.store.Size()) / float64(m.options.MaxPeers) |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
@ -551,9 +553,10 @@ func (m *PeerManager) DialFailed(address NodeAddress) error { |
|
|
case <-m.closeCh: |
|
|
case <-m.closeCh: |
|
|
} |
|
|
} |
|
|
}() |
|
|
}() |
|
|
|
|
|
} else { |
|
|
|
|
|
m.dialWaker.Wake() |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
m.dialWaker.Wake() |
|
|
|
|
|
return nil |
|
|
return nil |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|