mirror of
https://github.com/ipfs/kubo.git
synced 2026-02-21 18:37:45 +08:00
fix: take the lock while listing peers
This commit is contained in:
parent
a651045c50
commit
92854db7ae
@ -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}
|
||||
|
||||
Loading…
Reference in New Issue
Block a user