lightpush

package
v0.8.1-0...-4ef460c Latest Latest
Warning

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

Go to latest
Published: Jan 3, 2025 License: MIT Imports: 26 Imported by: 2

Documentation

Index

Constants

View Source
const LightPushENRField = uint8(1 << 3)
View Source
const LightPushID_v20beta1 = libp2pProtocol.ID("/vac/waku/lightpush/2.0.0-beta1")

LightPushID_v20beta1 is the current Waku LightPush 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 LightpushParameters

type LightpushParameters struct {
	// contains filtered or unexported fields
}

type Metrics added in v0.8.0

type Metrics interface {
	RecordMessage()
	RecordError(err metricsErrCategory)
}

Metrics exposes the functions required to update prometheus metrics for lightpush protocol

type Option added in v0.8.0

type Option func(*LightpushParameters)

func DefaultLightpushOptions

func DefaultLightpushOptions() []Option

func WithRateLimiter

func WithRateLimiter(r rate.Limit, b int) Option

WithRateLimiter is an option used to specify a rate limiter for requests received in lightpush protocol

type RequestOption

type RequestOption func(*lightPushRequestParameters) error

RequestOption is the type of options accepted when performing LightPush protocol requests

func DefaultOptions

func DefaultOptions(host host.Host) []RequestOption

DefaultOptions are the default options to be used when using the lightpush protocol

func WithAutomaticPeerSelection

func WithAutomaticPeerSelection(fromThesePeers ...peer.ID) RequestOption

WithAutomaticPeerSelection is an option used to randomly select a peer from the peer store to push a waku message to. 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 WithAutomaticRequestID added in v0.8.0

func WithAutomaticRequestID() RequestOption

WithAutomaticRequestID is an option to automatically generate a request ID when publishing a message

func WithDefaultPubsubTopic added in v0.9.0

func WithDefaultPubsubTopic() RequestOption

WithDefaultPubsubTopic is used to indicate that the message should be broadcasted in the default pubsub topic

func WithFastestPeerSelection

func WithFastestPeerSelection(fromThesePeers ...peer.ID) RequestOption

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 WithMaxPeers

func WithMaxPeers(num int) RequestOption

func WithPeer

func WithPeer(p peer.ID) RequestOption

WithPeer is an option used to specify the peerID to push a waku message to

func WithPeerAddr

func WithPeerAddr(pAddr multiaddr.Multiaddr) RequestOption

WithPeerAddr is an option used to specify a peerAddress This new peer will be added to peerStore. Note that this option is mutually exclusive to WithPeerAddr, only one of them can be used.

func WithPubSubTopic added in v0.8.1

func WithPubSubTopic(pubsubTopic string) RequestOption

WithPubSubTopic is used to specify the pubsub topic on which a WakuMessage will be broadcasted

func WithRequestID added in v0.8.0

func WithRequestID(requestID []byte) RequestOption

WithRequestID is an option to set a specific request ID to be used when publishing a message

type WakuLightPush

type WakuLightPush struct {
	// contains filtered or unexported fields
}

WakuLightPush is the implementation of the Waku LightPush protocol

func NewWakuLightPush

func NewWakuLightPush(relay *relay.WakuRelay, pm *peermanager.PeerManager, reg prometheus.Registerer, log *zap.Logger, opts ...Option) *WakuLightPush

NewWakuLightPush returns a new instance of Waku Lightpush struct Takes an optional peermanager if WakuLightPush is being created along with WakuNode. If using libp2p host, then pass peermanager as nil

func (*WakuLightPush) Publish

func (wakuLP *WakuLightPush) Publish(ctx context.Context, message *wpb.WakuMessage, opts ...RequestOption) (wpb.MessageHash, error)

Publish is used to broadcast a WakuMessage to the pubSubTopic (which is derived from the contentTopic) via lightpush protocol. If auto-sharding is not to be used, then the `WithPubSubTopic` option should be provided to publish the message to an specific pubSubTopic

func (*WakuLightPush) SetHost added in v0.6.0

func (wakuLP *WakuLightPush) SetHost(h host.Host)

Sets the host to be able to mount or consume a protocol

func (*WakuLightPush) Start

func (wakuLP *WakuLightPush) Start(ctx context.Context) error

Start inits the lighpush protocol

func (*WakuLightPush) Stop

func (wakuLP *WakuLightPush) Stop()

Stop unmounts the lightpush protocol

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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