filter

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: 27 Imported by: 2

Documentation

Index

Constants

View Source
const DefaultMaxSubscriptions = 1000
View Source
const FilterPushID_v20beta1 = libp2pProtocol.ID("/vac/waku/filter-push/2.0.0-beta1")

FilterPushID_v20beta1 is the current Waku Filter protocol identifier used to allow filter service nodes to push messages matching registered subscriptions to this client.

View Source
const FilterSubscribeID_v20beta1 = libp2pProtocol.ID("/vac/waku/filter-subscribe/2.0.0-beta1")

FilterSubscribeID_v20beta1 is the current Waku Filter protocol identifier for servers to allow filter clients to subscribe, modify, refresh and unsubscribe a desired set of filter criteria

View Source
const MaxContentTopicsPerRequest = 30
View Source
const MaxCriteriaPerSubscription = 1000
View Source
const MessagePushTimeout = 20 * time.Second

Variables

View Source
var (
	ErrNoPeersAvailable = errors.New("no suitable remote peers")
)

Functions

This section is empty.

Types

type FilterError added in v0.6.0

type FilterError struct {
	Code    int
	Message string
}

func NewFilterError added in v0.6.0

func NewFilterError(code int, message string) FilterError

func (*FilterError) Error added in v0.6.0

func (e *FilterError) Error() string

type FilterParameters

type FilterParameters struct {
	Timeout        time.Duration
	MaxSubscribers int
}

type FilterSubscribeOption

type FilterSubscribeOption func(*FilterSubscribeParameters)

func DefaultSubscriptionOptions added in v0.6.0

func DefaultSubscriptionOptions() []FilterSubscribeOption

func DefaultUnsubscribeOptions added in v0.6.0

func DefaultUnsubscribeOptions() []FilterSubscribeOption

func DontWait added in v0.8.0

func DontWait() FilterSubscribeOption

DontWait is used to fire and forget an unsubscription, and don't care about the results of it

func UnsubscribeAll added in v0.6.0

func UnsubscribeAll() FilterSubscribeOption

func WithAutomaticPeerSelection

func WithAutomaticPeerSelection(fromThesePeers ...peer.ID) FilterSubscribeOption

WithAutomaticPeerSelection is an option used to randomly select a peer from the peer store. If a list of specific peers is passed, the peer will be chosen from that list assuming it supports the chosen protocol, otherwise it will chose a peer from the node peerstore

func WithAutomaticRequestID added in v0.8.0

func WithAutomaticRequestID() FilterSubscribeOption

WithAutomaticRequestID is an option to automatically generate a request ID when creating a filter subscription

func WithFastestPeerSelection

func WithFastestPeerSelection(ctx context.Context, fromThesePeers ...peer.ID) FilterSubscribeOption

WithFastestPeerSelection is an option used to select a peer from the peer store with the lowest ping If a list of specific peers is passed, the peer will be chosen from that list assuming it supports the chosen protocol, otherwise it will chose a peer from the node peerstore

func WithPeer

func WithPeer(p peer.ID) FilterSubscribeOption

func WithRequestID added in v0.8.0

func WithRequestID(requestID []byte) FilterSubscribeOption

WithRequestID is an option to set a specific request ID to be used when creating/removing a filter subscription

func WithWaitGroup added in v0.8.0

func WithWaitGroup(wg *sync.WaitGroup) FilterSubscribeOption

WithWaitGroup allows specifying a waitgroup to wait until all unsubscribe requests are complete before the function is complete

type FilterSubscribeParameters

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

type Metrics added in v0.8.0

type Metrics interface {
	RecordMessage()
	RecordRequest(requestType string, duration time.Duration)
	RecordPushDuration(duration time.Duration)
	RecordSubscriptions(num int)
	RecordError(err metricsErrCategory)
}

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

type Option

type Option func(*FilterParameters)

func DefaultOptions

func DefaultOptions() []Option

func WithMaxSubscribers added in v0.6.0

func WithMaxSubscribers(maxSubscribers int) Option

func WithTimeout

func WithTimeout(timeout time.Duration) Option

type PeerSet added in v0.6.0

type PeerSet map[peer.ID]struct{}

type PubsubTopics added in v0.6.0

type PubsubTopics map[string]protocol.ContentTopicSet // pubsubTopic => contentTopics

type SubscribersMap added in v0.6.0

type SubscribersMap struct {
	sync.RWMutex
	// contains filtered or unexported fields
}

func NewSubscribersMap added in v0.6.0

func NewSubscribersMap(timeout time.Duration) *SubscribersMap

func (*SubscribersMap) Clear added in v0.6.0

func (sub *SubscribersMap) Clear()

func (*SubscribersMap) Count added in v0.6.0

func (sub *SubscribersMap) Count() int

func (*SubscribersMap) Delete added in v0.6.0

func (sub *SubscribersMap) Delete(peerID peer.ID, pubsubTopic string, contentTopics []string) error

func (*SubscribersMap) DeleteAll added in v0.6.0

func (sub *SubscribersMap) DeleteAll(peerID peer.ID) error

func (*SubscribersMap) FlagAsFailure added in v0.6.0

func (sub *SubscribersMap) FlagAsFailure(peerID peer.ID)

func (*SubscribersMap) FlagAsSuccess added in v0.6.0

func (sub *SubscribersMap) FlagAsSuccess(peerID peer.ID)

func (*SubscribersMap) Get added in v0.6.0

func (sub *SubscribersMap) Get(peerID peer.ID) (PubsubTopics, bool)

func (*SubscribersMap) Has added in v0.6.0

func (sub *SubscribersMap) Has(peerID peer.ID) bool

func (*SubscribersMap) IsFailedPeer added in v0.6.0

func (sub *SubscribersMap) IsFailedPeer(peerID peer.ID) bool

func (*SubscribersMap) Items added in v0.6.0

func (sub *SubscribersMap) Items(pubsubTopic string, contentTopic string) <-chan peer.ID

func (*SubscribersMap) RemoveAll added in v0.6.0

func (sub *SubscribersMap) RemoveAll()

func (*SubscribersMap) Set added in v0.6.0

func (sub *SubscribersMap) Set(peerID peer.ID, pubsubTopic string, contentTopics []string)

type WakuFilterFullNode added in v0.6.0

type WakuFilterFullNode struct {
	*protocol.CommonService
	// contains filtered or unexported fields
}

func NewWakuFilterFullNode added in v0.8.0

func NewWakuFilterFullNode(timesource timesource.Timesource, reg prometheus.Registerer, log *zap.Logger, opts ...Option) *WakuFilterFullNode

NewWakuFilterFullNode returns a new instance of Waku Filter struct setup according to the chosen parameter and options

func (*WakuFilterFullNode) SetHost added in v0.6.0

func (wf *WakuFilterFullNode) SetHost(h host.Host)

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

func (*WakuFilterFullNode) Start added in v0.6.0

func (*WakuFilterFullNode) Stop added in v0.6.0

func (wf *WakuFilterFullNode) Stop()

Stop unmounts the filter protocol

type WakuFilterLightNode added in v0.8.0

type WakuFilterLightNode struct {
	*protocol.CommonService
	// contains filtered or unexported fields
}

func NewWakuFilterLightNode added in v0.8.0

func NewWakuFilterLightNode(broadcaster relay.Broadcaster, pm *peermanager.PeerManager,
	timesource timesource.Timesource, reg prometheus.Registerer, log *zap.Logger) *WakuFilterLightNode

NewWakuFilterLightnode returns a new instance of Waku Filter struct setup according to the chosen parameter and options Note that broadcaster is optional. Takes an optional peermanager if WakuFilterLightnode is being created along with WakuNode. If using libp2p host, then pass peermanager as nil

func (*WakuFilterLightNode) FilterSubscription added in v0.8.0

func (wf *WakuFilterLightNode) FilterSubscription(peerID peer.ID, contentFilter protocol.ContentFilter) (*subscription.SubscriptionDetails, error)

FilterSubscription is used to obtain an object from which you could receive messages received via filter protocol

func (*WakuFilterLightNode) IsSubscriptionAlive added in v0.8.0

func (wf *WakuFilterLightNode) IsSubscriptionAlive(ctx context.Context, subscription *subscription.SubscriptionDetails) error

func (*WakuFilterLightNode) Ping added in v0.8.0

func (wf *WakuFilterLightNode) Ping(ctx context.Context, peerID peer.ID) error

func (*WakuFilterLightNode) SetHost added in v0.8.0

func (wf *WakuFilterLightNode) SetHost(h host.Host)

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

func (*WakuFilterLightNode) Start added in v0.8.0

func (wf *WakuFilterLightNode) Start(ctx context.Context) error

func (*WakuFilterLightNode) Stop added in v0.8.0

func (wf *WakuFilterLightNode) Stop()

Stop unmounts the filter protocol

func (*WakuFilterLightNode) Subscribe added in v0.8.0

Subscribe setups a subscription to receive messages that match a specific content filter If contentTopics passed result in different pubSub topics (due to Auto/Static sharding), then multiple subscription requests are sent to the peer. This may change if Filterv2 protocol is updated to handle such a scenario in a single request. Note: In case of partial failure, results are returned for successful subscriptions along with error indicating failed contentTopics.

func (*WakuFilterLightNode) Subscriptions added in v0.8.0

func (wf *WakuFilterLightNode) Subscriptions() []*subscription.SubscriptionDetails

func (*WakuFilterLightNode) Unsubscribe added in v0.8.0

func (wf *WakuFilterLightNode) Unsubscribe(ctx context.Context, contentFilter protocol.ContentFilter, opts ...FilterSubscribeOption) (<-chan WakuFilterPushResult, error)

Unsubscribe is used to stop receiving messages from a peer that match a content filter

func (*WakuFilterLightNode) UnsubscribeAll added in v0.8.0

func (wf *WakuFilterLightNode) UnsubscribeAll(ctx context.Context, opts ...FilterSubscribeOption) (<-chan WakuFilterPushResult, error)

UnsubscribeAll is used to stop receiving messages from peer(s). It does not close subscriptions

func (*WakuFilterLightNode) UnsubscribeWithSubscription added in v0.8.0

func (wf *WakuFilterLightNode) UnsubscribeWithSubscription(ctx context.Context, sub *subscription.SubscriptionDetails,
	opts ...FilterSubscribeOption) (<-chan WakuFilterPushResult, error)

UnsubscribeWithSubscription is used to close a particular subscription If there are no more subscriptions matching the passed [peer, contentFilter] pair, server unsubscribe is also performed

type WakuFilterPushResult added in v0.6.0

type WakuFilterPushResult struct {
	Err    error
	PeerID peer.ID
}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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