Skip to content

Commit

Permalink
fix: take the lock while listing peers
Browse files Browse the repository at this point in the history
  • Loading branch information
Stebalien authored and aschmahmann committed Sep 15, 2021
1 parent a651045 commit 92854db
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions peering/peering.go
Expand Up @@ -244,6 +244,9 @@ func (ps *PeeringService) AddPeer(info peer.AddrInfo) {

// ListPeers lists peers in the peering service.
func (ps *PeeringService) ListPeers() []peer.AddrInfo {
ps.mu.RLock()
defer ps.mu.RUnlock()

out := make([]peer.AddrInfo, 0, len(ps.peers))
for id, addrs := range ps.peers {
ai := peer.AddrInfo{ID: id}
Expand Down

0 comments on commit 92854db

Please sign in to comment.