relay

package
v0.6.0 Latest Latest
Warning

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

Go to latest
Published: May 12, 2023 License: MIT Imports: 27 Imported by: 4

Documentation

Index

Constants

View Source
const MessageWindowDuration = time.Minute * 5
View Source
const WakuRelayID_v200 = protocol.ID("/vac/waku/relay/2.0.0")

Variables

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

Functions

func MsgHash added in v0.6.0

func MsgHash(pubSubTopic string, msg *pb.WakuMessage) []byte

Application level message hash

func NewBroadcaster added in v0.6.0

func NewBroadcaster(bufLen int) *broadcaster

func PrivKeyToTopic added in v0.6.0

func PrivKeyToTopic(privKey *ecdsa.PrivateKey) string

func SignMessage added in v0.6.0

func SignMessage(privKey *ecdsa.PrivateKey, msg *pb.WakuMessage) error

Types

type Broadcaster added in v0.6.0

type Broadcaster interface {
	Start(ctx context.Context) error
	Stop()
	Register(topic string, chLen ...int) Subscription
	RegisterForAll(chLen ...int) Subscription
	Submit(*protocol.Envelope)
}

type Subscription

type Subscription struct {
	Unsubscribe func()
	Ch          <-chan *protocol.Envelope
}

func ArraySubscription added in v0.6.0

func ArraySubscription(msgs []*protocol.Envelope) Subscription

func NoopSubscription added in v0.6.0

func NoopSubscription() Subscription

type WakuRelay

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

func NewWakuRelay

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

NewWakuRelay returns a new instance of a WakuRelay struct

func (*WakuRelay) AddSignedTopicValidator added in v0.6.0

func (w *WakuRelay) AddSignedTopicValidator(topic string, address common.Address) error

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) IsSubscribed added in v0.6.0

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

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) SetHost added in v0.6.0

func (w *WakuRelay) SetHost(h host.Host)

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

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