func (pi Peers) GetPeers() []Peer {
	peers := pi.snapshot.Load().([]Peer)
	cpy := make([]Peer, len(peers))
	copy(cpy, peers)  
	pi.With().Info("now connected", log.Int("n_peers", len(cpy)))
	rand.Shuffle(len(cpy), func(i, j int) { cpy[i], cpy[j] = cpy[j], cpy[i] })  
	return cpy
}
GetPeers returns a snapshot of the connected peers shuffled.
package p2p
import (
	"sync/atomic"
	"github.com/libonomy/libonomy-p2p/log"
	"github.com/libonomy/libonomy-p2p/p2p/p2pcrypto"
	"github.com/libonomy/libonomy-p2p/rand"
)
type Peer p2pcrypto.PublicKey
type Peers struct {
	log.Log
	snapshot *atomic.Value
	exit     chan struct{}
}
func NewPeersImpl(snapshot *atomic.Value, exit chan struct{}, lg log.Log) *Peers {
	return &Peers{snapshot: snapshot, Log: lg, exit: exit}
}
type PeerSubscriptionProvider interface {
	SubscribePeerEvents() (conn, disc chan p2pcrypto.PublicKey)
}
func NewPeers(s PeerSubscriptionProvider, lg log.Log) *Peers {
	value := atomic.Value{}
	value.Store(make([]Peer, 0, 20))
	pi := NewPeersImpl(&value, make(chan struct{}), lg)
	newPeerC, expiredPeerC := s.SubscribePeerEvents()
	go pi.listenToPeers(newPeerC, expiredPeerC)
	return pi
}
func (pi Peers) Close() {
	close(pi.exit)
}