Documentation ¶
Index ¶
Constants ¶
const MaxCacheSize = 1000
const PeerExchangeID_v20alpha1 = libp2pProtocol.ID("/vac/waku/peer-exchange/2.0.0-alpha1")
PeerExchangeID_v20alpha1 is the current Waku Peer Exchange protocol identifier
Variables ¶
var ( ErrNoPeersAvailable = errors.New("no suitable remote peers") ErrInvalidID = errors.New("invalid request id") )
Functions ¶
This section is empty.
Types ¶
type Metrics ¶ added in v0.8.0
type Metrics interface {
RecordError(err metricsErrCategory)
}
Metrics exposes the functions required to update prometheus metrics for peer_exchange protocol
type PeerConnector ¶ added in v0.4.0
type PeerConnector interface {
Subscribe(context.Context, <-chan peermanager.PeerData)
}
PeerConnector will subscribe to a channel containing the information for all peers found by this discovery protocol
type PeerExchangeOption ¶
type PeerExchangeOption func(*PeerExchangeParameters)
func DefaultOptions ¶
func DefaultOptions(host host.Host) []PeerExchangeOption
DefaultOptions are the default options to be used when using the lightpush protocol
func WithAutomaticPeerSelection ¶
func WithAutomaticPeerSelection(fromThesePeers ...peer.ID) PeerExchangeOption
WithAutomaticPeerSelection is an option used to randomly select a peer from the peer store to obtains peers from. If a list of specific peers is passed, the peer will be chosen from that list assuming it supports the chosen protocol, otherwise it will chose a peer from the node peerstore
func WithFastestPeerSelection ¶
func WithFastestPeerSelection(ctx context.Context, fromThesePeers ...peer.ID) PeerExchangeOption
WithFastestPeerSelection is an option used to select a peer from the peer store with the lowest ping. If a list of specific peers is passed, the peer will be chosen from that list assuming it supports the chosen protocol, otherwise it will chose a peer from the node peerstore
func WithPeer ¶
func WithPeer(p peer.ID) PeerExchangeOption
WithPeer is an option used to specify the peerID to push a waku message to
type PeerExchangeParameters ¶
type PeerExchangeParameters struct {
// contains filtered or unexported fields
}
type WakuPeerExchange ¶
type WakuPeerExchange struct { *protocol.CommonService // contains filtered or unexported fields }
func NewWakuPeerExchange ¶
func NewWakuPeerExchange(disc *discv5.DiscoveryV5, peerConnector PeerConnector, pm *peermanager.PeerManager, reg prometheus.Registerer, log *zap.Logger) (*WakuPeerExchange, error)
NewWakuPeerExchange returns a new instance of WakuPeerExchange struct Takes an optional peermanager if WakuPeerExchange is being created along with WakuNode. If using libp2p host, then pass peermanager as nil
func (*WakuPeerExchange) Request ¶
func (wakuPX *WakuPeerExchange) Request(ctx context.Context, numPeers int, opts ...PeerExchangeOption) error
func (*WakuPeerExchange) SetHost ¶ added in v0.6.0
func (wakuPX *WakuPeerExchange) SetHost(h host.Host)
SetHost sets the host to be able to mount or consume a protocol
func (*WakuPeerExchange) Start ¶
func (wakuPX *WakuPeerExchange) Start(ctx context.Context) error
Start inits the peer exchange protocol
func (*WakuPeerExchange) Stop ¶
func (wakuPX *WakuPeerExchange) Stop()
Stop unmounts the peer exchange protocol