Skip to content
This repository has been archived by the owner on Aug 19, 2022. It is now read-only.

stop using the peer.Set #201

Merged
merged 1 commit into from
Jun 27, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 7 additions & 3 deletions pstoremem/addr_book.go
Original file line number Diff line number Diff line change
Expand Up @@ -147,17 +147,21 @@ func (mab *memoryAddrBook) gc() {

func (mab *memoryAddrBook) PeersWithAddrs() peer.IDSlice {
// deduplicate, since the same peer could have both signed & unsigned addrs
pidSet := peer.NewSet()
set := make(map[peer.ID]struct{})
for _, s := range mab.segments {
s.RLock()
for pid, amap := range s.addrs {
if len(amap) > 0 {
pidSet.Add(pid)
set[pid] = struct{}{}
}
}
s.RUnlock()
}
return pidSet.Peers()
peers := make(peer.IDSlice, 0, len(set))
for pid := range set {
peers = append(peers, pid)
}
return peers
}

// AddAddr calls AddAddrs(p, []ma.Multiaddr{addr}, ttl)
Expand Down