relay

package
v0.5.0 Latest Latest
Warning

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

Go to latest
Published: Feb 17, 2023 License: MIT Imports: 20 Imported by: 4

Documentation

Index

Constants

View Source
const WakuRelayID_v200 = protocol.ID("/vac/waku/relay/2.0.0")

Variables

View Source
var DefaultWakuTopic string = waku_proto.DefaultPubsubTopic().String()

Functions

This section is empty.

Types

type Subscription

type Subscription struct {
	sync.RWMutex

	// C is channel used for receiving envelopes
	C chan *protocol.Envelope
	// contains filtered or unexported fields
}

Subscription handles the subscrition to a particular pubsub topic

func (*Subscription) IsClosed

func (subs *Subscription) IsClosed() bool

IsClosed determine whether a Subscription is still open for receiving messages

func (*Subscription) Unsubscribe

func (subs *Subscription) Unsubscribe()

Unsubscribe will close a subscription from a pubsub topic. Will close the message channel

type WakuRelay

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

func NewWakuRelay

func NewWakuRelay(h host.Host, bcaster v2.Broadcaster, minPeersToPublish int, timesource timesource.Timesource, log *zap.Logger, opts ...pubsub.Option) *WakuRelay

NewWakuRelay returns a new instance of a WakuRelay struct

func (*WakuRelay) EnoughPeersToPublish

func (w *WakuRelay) EnoughPeersToPublish() bool

EnoughPeersToPublish returns whether there are enough peers connected in the default waku pubsub topic

func (*WakuRelay) EnoughPeersToPublishToTopic

func (w *WakuRelay) EnoughPeersToPublishToTopic(topic string) bool

EnoughPeersToPublish returns whether there are enough peers connected in a pubsub topic

func (*WakuRelay) PubSub

func (w *WakuRelay) PubSub() *pubsub.PubSub

PubSub returns the implementation of the pubsub system

func (*WakuRelay) Publish

func (w *WakuRelay) Publish(ctx context.Context, message *pb.WakuMessage) ([]byte, error)

Publish is used to broadcast a WakuMessage to the default waku pubsub topic

func (*WakuRelay) PublishToTopic

func (w *WakuRelay) PublishToTopic(ctx context.Context, message *pb.WakuMessage, topic string) ([]byte, error)

PublishToTopic is used to broadcast a WakuMessage to a pubsub topic

func (*WakuRelay) SetPubSub

func (w *WakuRelay) SetPubSub(pubSub *pubsub.PubSub)

SetPubSub is used to set an implementation of the pubsub system

func (*WakuRelay) Start added in v0.4.0

func (w *WakuRelay) Start(ctx context.Context) error

func (*WakuRelay) Stop

func (w *WakuRelay) Stop()

Stop unmounts the relay protocol and stops all subscriptions

func (*WakuRelay) Subscribe

func (w *WakuRelay) Subscribe(ctx context.Context) (*Subscription, error)

SubscribeToTopic returns a Subscription to receive messages from the default waku pubsub topic

func (*WakuRelay) SubscribeToTopic

func (w *WakuRelay) SubscribeToTopic(ctx context.Context, topic string) (*Subscription, error)

SubscribeToTopic returns a Subscription to receive messages from a pubsub topic

func (*WakuRelay) Topics

func (w *WakuRelay) Topics() []string

Topics returns a list of all the pubsub topics currently subscribed to

func (*WakuRelay) Unsubscribe

func (w *WakuRelay) Unsubscribe(ctx context.Context, topic string) error

Unsubscribe closes a subscription to a pubsub topic

Jump to

Keyboard shortcuts

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