filter

package
v0.4.0 Latest Latest
Warning

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

Go to latest
Published: Jan 23, 2023 License: MIT Imports: 23 Imported by: 2

Documentation

Index

Constants

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

FilterID_v20beta1 is the current Waku Filter protocol identifier

Variables

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

Functions

This section is empty.

Types

type ContentFilter

type ContentFilter struct {
	Topic         string
	ContentTopics []string
}

type Filter

type Filter struct {
	PeerID         peer.ID
	Topic          string
	ContentFilters []string
	Chan           chan *protocol.Envelope
	// contains filtered or unexported fields
}

type FilterMap

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

func NewFilterMap

func NewFilterMap(broadcaster v2.Broadcaster, timesource timesource.Timesource) *FilterMap

func (*FilterMap) Delete

func (fm *FilterMap) Delete(key string)

func (*FilterMap) Get

func (fm *FilterMap) Get(key string) (Filter, bool)

func (*FilterMap) Items

func (fm *FilterMap) Items() <-chan FilterMapItem

func (*FilterMap) Notify

func (fm *FilterMap) Notify(msg *pb.WakuMessage, requestId string)

func (*FilterMap) RemoveAll

func (fm *FilterMap) RemoveAll()

func (*FilterMap) Set

func (fm *FilterMap) Set(key string, value Filter)

type FilterMapItem

type FilterMapItem struct {
	Key   string
	Value Filter
}

type FilterParameters

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

type FilterSubscribeOption

type FilterSubscribeOption func(*FilterSubscribeParameters)

func DefaultSubscribtionOptions

func DefaultSubscribtionOptions() []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 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

type FilterSubscribeParameters

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

type FilterSubscription

type FilterSubscription struct {
	RequestID string
	Peer      peer.ID
}

type Option

type Option func(*FilterParameters)

func DefaultOptions

func DefaultOptions() []Option

func WithTimeout

func WithTimeout(timeout time.Duration) Option

type Subscriber

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

func (Subscriber) HasContentTopic

func (sub Subscriber) HasContentTopic(topic string) bool

type Subscribers

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

func NewSubscribers

func NewSubscribers(timeout time.Duration) *Subscribers

func (*Subscribers) Append

func (sub *Subscribers) Append(s Subscriber) int

func (*Subscribers) Clear added in v0.4.0

func (sub *Subscribers) Clear()

func (*Subscribers) FlagAsFailure

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

func (*Subscribers) FlagAsSuccess

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

func (*Subscribers) IsFailedPeer

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

func (*Subscribers) Items

func (sub *Subscribers) Items(contentTopic *string) <-chan Subscriber

func (*Subscribers) Length

func (sub *Subscribers) Length() int

func (*Subscribers) RemoveContentFilters

func (sub *Subscribers) RemoveContentFilters(peerID peer.ID, requestId string, contentFilters []*pb.FilterRequest_ContentFilter)

type WakuFilter

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

func NewWakuFilter

func NewWakuFilter(host host.Host, broadcaster v2.Broadcaster, isFullNode bool, timesource timesource.Timesource, log *zap.Logger, opts ...Option) *WakuFilter

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

func (*WakuFilter) MessageChannel added in v0.4.0

func (wf *WakuFilter) MessageChannel() chan *protocol.Envelope

func (*WakuFilter) Start added in v0.4.0

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

func (*WakuFilter) Stop

func (wf *WakuFilter) Stop()

Stop unmounts the filter protocol

func (*WakuFilter) Subscribe

func (wf *WakuFilter) Subscribe(ctx context.Context, f ContentFilter, opts ...FilterSubscribeOption) (filterID string, theFilter Filter, err error)

Subscribe setups a subscription to receive messages that match a specific content filter

func (*WakuFilter) Unsubscribe

func (wf *WakuFilter) Unsubscribe(ctx context.Context, contentFilter ContentFilter, peer peer.ID) error

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

func (*WakuFilter) UnsubscribeByFilter

func (wf *WakuFilter) UnsubscribeByFilter(ctx context.Context, filter Filter) error

UnsubscribeFilterByID removes a subscription to a filter node completely using using a filter. It also closes the filter channel

func (*WakuFilter) UnsubscribeFilter

func (wf *WakuFilter) UnsubscribeFilter(ctx context.Context, cf ContentFilter) error

Unsubscribe filter removes content topics from a filter subscription. If all the contentTopics are removed the subscription is dropped completely

func (*WakuFilter) UnsubscribeFilterByID

func (wf *WakuFilter) UnsubscribeFilterByID(ctx context.Context, filterID string) error

UnsubscribeFilterByID removes a subscription to a filter node completely using the filterID returned when the subscription was created

Jump to

Keyboard shortcuts

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