Documentation ¶
Index ¶
- Constants
- Variables
- func NewBroadcaster(bufLen int) *broadcaster
- func SignMessage(privKey *ecdsa.PrivateKey, msg *pb.WakuMessage, pubsubTopic string) error
- type Broadcaster
- type BroadcasterOption
- type BroadcasterParameters
- type EvtPeerTopic
- type EvtRelaySubscribed
- type EvtRelayUnsubscribed
- type Metrics
- type PeerTopicState
- type PublishOption
- type RelaySubscribeOption
- type RelaySubscribeParameters
- type Subscription
- type SubscriptionType
- type Subscriptions
- type WakuRelay
- func (w *WakuRelay) AddSignedTopicValidator(topic string, publicKey *ecdsa.PublicKey) error
- func (w *WakuRelay) CreateEventEmitters() error
- func (w *WakuRelay) EnoughPeersToPublish() bool
- func (w *WakuRelay) EnoughPeersToPublishToTopic(topic string) bool
- func (w *WakuRelay) Events() event.Bus
- func (w *WakuRelay) GetSubscription(contentTopic string) (*Subscription, error)
- func (w *WakuRelay) GetSubscriptionWithPubsubTopic(pubsubTopic string, contentTopic string) (*Subscription, error)
- 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, opts ...PublishOption) ([]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, contentFilter waku_proto.ContentFilter, ...) ([]*Subscription, error)
- func (w *WakuRelay) Topics() []string
- func (w *WakuRelay) Unsubscribe(ctx context.Context, contentFilter waku_proto.ContentFilter) error
Constants ¶
const ( PEER_JOINED = iota PEER_LEFT )
const WakuRelayENRField = uint8(1 << 0)
const WakuRelayID_v200 = protocol.ID("/vac/waku/relay/2.0.0")
WakuRelayID_v200 is the current protocol ID used for WakuRelay
Variables ¶
var DefaultRelaySubscriptionBufferSize int = 1024
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(contentFilter protocol.ContentFilter, opts ...BroadcasterOption) *Subscription RegisterForAll(opts ...BroadcasterOption) *Subscription UnRegister(pubsubTopic string) 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 BroadcasterOption ¶ added in v0.9.0
type BroadcasterOption func(*BroadcasterParameters)
func DefaultBroadcasterOptions ¶ added in v0.9.0
func DefaultBroadcasterOptions() []BroadcasterOption
DefaultBroadcasterOptions specifies default options for broadcaster
func DontConsume ¶ added in v0.9.0
func DontConsume() BroadcasterOption
WithoutConsumer option let's a user subscribe to a broadcaster without consuming messages received. This is useful for a relayNode where only a subscribe is required in order to relay messages in gossipsub network.
func WithBufferSize ¶ added in v0.9.0
func WithBufferSize(size int) BroadcasterOption
WithBufferSize option let's a user set channel buffer to be set.
func WithConsumerOption ¶ added in v0.9.0
func WithConsumerOption(dontConsume bool) BroadcasterOption
type BroadcasterParameters ¶ added in v0.9.0
type BroadcasterParameters struct {
// contains filtered or unexported fields
}
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 PublishOption ¶ added in v0.9.0
type PublishOption func(*publishParameters)
PublishOption is the type of options accepted when publishing WakuMessages
func WithDefaultPubsubTopic ¶ added in v0.9.0
func WithDefaultPubsubTopic() PublishOption
WithPubSubTopic is used to indicate that the message should be broadcasted in the default pubsub topic
func WithPubSubTopic ¶ added in v0.9.0
func WithPubSubTopic(pubsubTopic string) PublishOption
WithPubSubTopic is used to specify the pubsub topic on which a WakuMessage will be broadcasted
type RelaySubscribeOption ¶ added in v0.9.0
type RelaySubscribeOption func(*RelaySubscribeParameters) error
func WithCacheSize ¶ added in v0.9.0
func WithCacheSize(size uint) RelaySubscribeOption
func WithoutConsumer ¶ added in v0.9.0
func WithoutConsumer() RelaySubscribeOption
WithoutConsumer option let's a user subscribe to relay without consuming messages received. This is useful for a relayNode where only a subscribe is required in order to relay messages in gossipsub network.
type RelaySubscribeParameters ¶ added in v0.9.0
type RelaySubscribeParameters struct {
// contains filtered or unexported fields
}
type Subscription ¶
type Subscription struct { ID int Unsubscribe func() //for internal use only. For relay Subscription use relay protocol's unsubscribe Ch chan *protocol.Envelope // contains filtered or unexported fields }
Subscription handles the details of a particular Topic subscription. There may be many subscriptions for a given topic.
func NewSubscription ¶ added in v0.9.0
func NewSubscription(contentFilter protocol.ContentFilter) *Subscription
NewSubscription creates a subscription that will only receive messages based on the contentFilter
type SubscriptionType ¶ added in v0.9.0
type SubscriptionType int
const ( SpecificContentTopics SubscriptionType = iota AllContentTopics )
type Subscriptions ¶ added in v0.9.0
type Subscriptions struct {
// contains filtered or unexported fields
}
type WakuRelay ¶
type WakuRelay struct { *service.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) CreateEventEmitters ¶ added in v0.9.0
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) GetSubscription ¶ added in v0.9.0
func (w *WakuRelay) GetSubscription(contentTopic string) (*Subscription, error)
GetSubscription fetches subscription matching a contentTopic(via autosharding)
func (*WakuRelay) GetSubscriptionWithPubsubTopic ¶ added in v0.9.0
func (w *WakuRelay) GetSubscriptionWithPubsubTopic(pubsubTopic string, contentTopic string) (*Subscription, error)
GetSubscriptionWithPubsubTopic fetches subscription matching pubsub and contentTopic
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 ¶
func (w *WakuRelay) Publish(ctx context.Context, message *pb.WakuMessage, opts ...PublishOption) ([]byte, error)
PublishToTopic is used to broadcast a WakuMessage to a pubsub topic. The pubsubTopic is derived from contentTopic specified in the message via autosharding. To publish to a specific pubsubTopic, the `WithPubSubTopic` option should be provided
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, contentFilter waku_proto.ContentFilter, opts ...RelaySubscribeOption) ([]*Subscription, error)
Subscribe returns a Subscription to receive messages as per contentFilter contentFilter can contain pubSubTopic and contentTopics or only contentTopics(in case of autosharding)
func (*WakuRelay) Unsubscribe ¶
func (w *WakuRelay) Unsubscribe(ctx context.Context, contentFilter waku_proto.ContentFilter) error
Unsubscribe closes a subscription to a pubsub topic