Documentation
¶
Index ¶
- Constants
- Variables
- func NewBroadcaster(bufLen int) *broadcaster
- func SignMessage(privKey *ecdsa.PrivateKey, msg *pb.WakuMessage, pubsubTopic string) error
- type Broadcaster
- type EvtPeerTopic
- type EvtRelaySubscribed
- type EvtRelayUnsubscribed
- type Metrics
- type PeerTopicState
- type Subscription
- type WakuRelay
- func (w *WakuRelay) AddSignedTopicValidator(topic string, publicKey *ecdsa.PublicKey) error
- func (w *WakuRelay) EnoughPeersToPublish() bool
- func (w *WakuRelay) EnoughPeersToPublishToTopic(topic string) bool
- func (w *WakuRelay) Events() event.Bus
- func (w *WakuRelay) IsSubscribed(topic string) bool
- func (w *WakuRelay) Params() pubsub.GossipSubParams
- func (w *WakuRelay) PubSub() *pubsub.PubSub
- func (w *WakuRelay) Publish(ctx context.Context, message *pb.WakuMessage) ([]byte, error)
- func (w *WakuRelay) PublishToTopic(ctx context.Context, message *pb.WakuMessage, topic string) ([]byte, error)
- func (w *WakuRelay) RegisterDefaultValidator(fn validatorFn)
- func (w *WakuRelay) RegisterTopicValidator(topic string, fn validatorFn)
- func (w *WakuRelay) RemoveTopicValidator(topic string)
- func (w *WakuRelay) SetHost(h host.Host)
- func (w *WakuRelay) SetPubSub(pubSub *pubsub.PubSub)
- func (w *WakuRelay) Start(ctx context.Context) error
- func (w *WakuRelay) Stop()
- func (w *WakuRelay) Subscribe(ctx context.Context) (*Subscription, error)
- func (w *WakuRelay) SubscribeToTopic(ctx context.Context, topic string) (*Subscription, error)
- func (w *WakuRelay) Topics() []string
- func (w *WakuRelay) Unsubscribe(ctx context.Context, topic string) error
Constants ¶
const ( PEER_JOINED = iota PEER_LEFT )
const WakuRelayID_v200 = protocol.ID("/vac/waku/relay/2.0.0")
WakuRelayID_v200 is the current protocol ID used for WakuRelay
Variables ¶
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
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 ¶
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
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 ¶
EnoughPeersToPublish returns whether there are enough peers connected in the default waku pubsub topic
func (*WakuRelay) EnoughPeersToPublishToTopic ¶
EnoughPeersToPublish returns whether there are enough peers connected in a pubsub topic
func (*WakuRelay) Events ¶ added in v0.8.0
Events returns the event bus on which WakuRelay events will be emitted
func (*WakuRelay) IsSubscribed ¶ added in v0.6.0
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) Publish ¶
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 (*WakuRelay) RemoveTopicValidator ¶ added in v0.8.0
func (*WakuRelay) SetHost ¶ added in v0.6.0
SetHost sets the host to be able to mount or consume a 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 ¶
SubscribeToTopic returns a Subscription to receive messages from a pubsub topic