func (p *Peers) GetPeers() []peer.ID {
	peers, _ := p.snapshot.Load().([]peer.ID)
	return peers
}
GetPeers returns a snapshot of the connected peers shuffled.
package bootstrap
import (
	"context"
	"sync/atomic"
	"github.com/libp2p/go-libp2p-core/event"
	"github.com/libp2p/go-libp2p-core/host"
	"github.com/libp2p/go-libp2p-core/network"
	"github.com/libp2p/go-libp2p-core/peer"
	"golang.org/x/sync/errgroup"
	"github.com/spacemeshos/go-spacemesh/log"
)
type waitPeersReq struct {
	ch  chan []peer.ID
	min int
}
type Opt func(*Peers)
func WithLog(logger log.Log) Opt {
	return func(p *Peers) {
		p.logger = logger
	}
}
func WithNodeReporter(f func()) Opt {
	return func(p *Peers) {
		p.nodeReporter = f
	}
}
func WithContext(ctx context.Context) Opt {
	return func(p *Peers) {
		p.ctx = ctx
	}
}
func StartPeers(h host.Host, opts ...Opt) *Peers {
	p := newPeers(h, opts...)
	p.Start()
	return p
}
type Provider interface {
	PeerCount() uint64
	GetPeers() []peer.ID
}
type Waiter interface {
	WaitPeers(context.Context, int) ([]peer.ID, error)
}
func newPeers(h host.Host, opts ...Opt) *Peers {
	p := &Peers{
		h:        h,
		logger:   log.NewNop(),
		ctx:      context.Background(),
		requests: make(chan *waitPeersReq),
	}
	p.snapshot.Store(make([]peer.ID, 0, 20))
	for _, opt := range opts {
		opt(p)
	}
	p.ctx, p.cancel = context.WithCancel(p.ctx)
	return p
}
type Peers struct {
	logger   log.Log
	h        host.Host
	snapshot atomic.Value
	requests chan *waitPeersReq
	eg     errgroup.Group
	ctx    context.Context
	cancel context.CancelFunc
	nodeReporter func()
}
func (p *Peers) Stop() {
	p.cancel()
	p.eg.Wait()
}