peer_exchange

package
v0.9.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 14, 2023 License: MIT Imports: 29 Imported by: 1

Documentation

Index

Constants

View Source
const MaxCacheSize = 1000
View Source
const PeerExchangeID_v20alpha1 = libp2pProtocol.ID("/vac/waku/peer-exchange/2.0.0-alpha1")

PeerExchangeID_v20alpha1 is the current Waku Peer Exchange protocol identifier

Variables

View Source
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 service.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 Waku 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 Note: this option can only be used if WakuNode is initialized which internally intializes the peerManager

func WithFastestPeerSelection

func WithFastestPeerSelection(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 {
	*service.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

Directories

Path Synopsis

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL