lightpush

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: 20 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 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)

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

func DefaultOptions

func DefaultOptions(host host.Host) []Option

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

func WithAutomaticPeerSelection

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

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() Option

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

func WithDefaultPubsubTopic added in v0.9.0

func WithDefaultPubsubTopic() Option

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

func WithFastestPeerSelection

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

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) Option

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

func WithPubSubTopic added in v0.8.1

func WithPubSubTopic(pubsubTopic string) Option

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) Option

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) *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 ...Option) ([]byte, 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