relay

package
v0.8.1 Latest Latest
Warning

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

Go to latest
Published: Oct 7, 2023 License: MIT Imports: 28 Imported by: 4

Documentation

Index

Constants

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

WakuRelayID_v200 is the current protocol ID used for WakuRelay

Variables

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

DefaultWakuTopic is the default pubsub topic used across all Waku protocols

Functions

func NewBroadcaster added in v0.6.0

func NewBroadcaster(bufLen int) *broadcaster

NewBroadcaster creates a new instance of a broadcaster

func SignMessage added in v0.6.0

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

SignMessage adds an ECDSA signature to a WakuMessage as an opt-in mechanism for DoS prevention

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

Broadcaster is used to create a fanout for an envelope that will be received by any subscriber interested in the topic of the message

type EvtPeerTopic added in v0.8.1

type EvtPeerTopic struct {
	PubsubTopic string
	PeerID      peer.ID
	State       PeerTopicState
}

type EvtRelaySubscribed added in v0.8.0

type EvtRelaySubscribed struct {
	Topic     string
	TopicInst *pubsub.Topic
}

EvtRelaySubscribed is an event emitted when a new subscription to a pubsub topic is created

type EvtRelayUnsubscribed added in v0.8.0

type EvtRelayUnsubscribed struct {
	Topic string
}

EvtRelayUnsubscribed is an event emitted when a subscription to a pubsub topic is closed

type Metrics added in v0.8.0

type Metrics interface {
	RecordMessage(envelope *waku_proto.Envelope)
}

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

type PeerTopicState added in v0.8.1

type PeerTopicState int

type Subscription

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

Subscription handles the details of a particular Topic subscription. There may be many subscriptions for a given topic.

func ArraySubscription added in v0.6.0

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

ArraySubscription creates a subscription for a list of envelopes

func NoopSubscription added in v0.6.0

func NoopSubscription() Subscription

NoopSubscription creates a noop subscription that will not receive any envelope

type WakuRelay

type WakuRelay struct {
	*waku_proto.CommonService
	// contains filtered or unexported fields
}

WakuRelay is the implementation of the Waku Relay protocol

func NewWakuRelay

func NewWakuRelay(bcaster Broadcaster, minPeersToPublish int, timesource timesource.Timesource, reg prometheus.Registerer, 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, publicKey *ecdsa.PublicKey) error

AddSignedTopicValidator registers a gossipsub validator for a topic which will check that messages Meta field contains a valid ECDSA signature for the specified pubsub topic. This is used as a DoS prevention mechanism

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) Events added in v0.8.0

func (w *WakuRelay) Events() event.Bus

Events returns the event bus on which WakuRelay events will be emitted

func (*WakuRelay) IsSubscribed added in v0.6.0

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

IsSubscribed indicates whether the node is subscribed to a pubsub topic or not

func (*WakuRelay) Params added in v0.7.0

func (w *WakuRelay) Params() pubsub.GossipSubParams

Params returns the gossipsub configuration parameters used by WakuRelay

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) RegisterDefaultValidator added in v0.8.0

func (w *WakuRelay) RegisterDefaultValidator(fn validatorFn)

func (*WakuRelay) RegisterTopicValidator added in v0.8.0

func (w *WakuRelay) RegisterTopicValidator(topic string, fn validatorFn)

func (*WakuRelay) RemoveTopicValidator added in v0.8.0

func (w *WakuRelay) RemoveTopicValidator(topic string)

func (*WakuRelay) SetHost added in v0.6.0

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

SetHost 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

Start initiates the WakuRelay protocol

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)

Subscribe 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