Skip to content

Commit

Permalink
feat: export PeerSample and peers field
Browse files Browse the repository at this point in the history
- Export PeerSample type
- Add documentation
- Export peers field from PeerSampler
  • Loading branch information
Elvis339 committed Feb 26, 2025
1 parent 06777fd commit 4c1da47
Showing 1 changed file with 8 additions and 7 deletions.
15 changes: 8 additions & 7 deletions network/p2p/network.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ import (
var (
_ validators.Connector = (*Network)(nil)
_ common.AppHandler = (*Network)(nil)
_ NodeSampler = (*peerSampler)(nil)
_ NodeSampler = (*PeerSampler)(nil)

opLabel = "op"
handlerLabel = "handlerID"
Expand Down Expand Up @@ -144,8 +144,8 @@ func (n *Network) NewClient(handlerID uint64, options ...ClientOption) *Client {
sender: n.sender,
router: n.router,
options: &clientOptions{
nodeSampler: &peerSampler{
peers: n.Peers,
nodeSampler: &PeerSampler{
Peers: n.Peers,
},
},
}
Expand Down Expand Up @@ -197,12 +197,13 @@ func (p *Peers) Sample(limit int) []ids.NodeID {
return p.set.Sample(limit)
}

type peerSampler struct {
peers *Peers
// PeerSampler implements NodeSampler
type PeerSampler struct {
Peers *Peers
}

func (p peerSampler) Sample(_ context.Context, limit int) []ids.NodeID {
return p.peers.Sample(limit)
func (p PeerSampler) Sample(_ context.Context, limit int) []ids.NodeID {
return p.Peers.Sample(limit)
}

func ProtocolPrefix(handlerID uint64) []byte {
Expand Down

0 comments on commit 4c1da47

Please sign in to comment.