Browse Source

p2p: address audit issues with the peer manager (#6603)

pull/6608/head
Sam Kleinman 3 years ago
committed by GitHub
parent
commit
bed58a749f
No known key found for this signature in database GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 6 additions and 3 deletions
  1. +6
    -3
      internal/p2p/peermanager.go

+ 6
- 3
internal/p2p/peermanager.go View File

@ -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
} }


Loading…
Cancel
Save