Documentation ¶
Index ¶
- Constants
- Variables
- type Metrics
- type Option
- func DefaultOptions(host host.Host) []Option
- func WithAutomaticPeerSelection(fromThesePeers ...peer.ID) Option
- func WithAutomaticRequestID() Option
- func WithFastestPeerSelection(ctx context.Context, fromThesePeers ...peer.ID) Option
- func WithPeer(p peer.ID) Option
- func WithRequestID(requestID []byte) Option
- type WakuLightPush
- func (wakuLP *WakuLightPush) Publish(ctx context.Context, message *wpb.WakuMessage, opts ...Option) ([]byte, error)
- func (wakuLP *WakuLightPush) PublishToTopic(ctx context.Context, message *wpb.WakuMessage, topic string, opts ...Option) ([]byte, error)
- func (wakuLP *WakuLightPush) SetHost(h host.Host)
- func (wakuLP *WakuLightPush) Start(ctx context.Context) error
- func (wakuLP *WakuLightPush) Stop()
Constants ¶
const LightPushID_v20beta1 = libp2pProtocol.ID("/vac/waku/lightpush/2.0.0-beta1")
LightPushID_v20beta1 is the current Waku LightPush 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 { 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 ¶
DefaultOptions are the default options to be used when using the lightpush protocol
func WithAutomaticPeerSelection ¶
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 WithFastestPeerSelection ¶
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 WithRequestID ¶ added in v0.8.0
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 default waku pubsub topic via lightpush protocol
func (*WakuLightPush) PublishToTopic ¶
func (wakuLP *WakuLightPush) PublishToTopic(ctx context.Context, message *wpb.WakuMessage, topic string, opts ...Option) ([]byte, error)
PublishToTopic is used to broadcast a WakuMessage to a pubsub topic via lightpush protocol
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