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 PeerConnector ¶ added in v0.4.0
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 {
// contains filtered or unexported fields
}
func NewWakuPeerExchange ¶
func NewWakuPeerExchange(disc *discv5.DiscoveryV5, peerConnector PeerConnector, log *zap.Logger) (*WakuPeerExchange, error)
NewWakuPeerExchange returns a new instance of WakuPeerExchange struct
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)
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