Skip to content

Commit

Permalink
add method to peerset for returning all peers in set
Browse files Browse the repository at this point in the history
  • Loading branch information
whyrusleeping committed Mar 5, 2017
1 parent c022ceb commit 962a676
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions peerset/peerset.go
Original file line number Diff line number Diff line change
Expand Up @@ -60,3 +60,13 @@ func (ps *PeerSet) TryAdd(p peer.ID) bool {
ps.lk.Unlock()
return success
}

func (ps *PeerSet) Peers() []peer.ID {
ps.lk.Lock()
out := make([]peer.ID, 0, len(ps.ps))
for p, _ := range ps.ps {
out = append(out, p)
}
ps.lk.Unlock()
return out
}

0 comments on commit 962a676

Please sign in to comment.