filters

package
v1.7.0 Latest Latest
Warning

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

Go to latest
Published: Mar 30, 2022 License: GPL-3.0 Imports: 13 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type ChainEvent

type ChainEvent struct {
	Block *model.Block
	Hash  common.Hash
	Logs  []*model.Log
}

type EventSystem

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

EventSystem creates subscriptions, processes events and broadcasts them to the subscription which match the subscription criteria.

func NewEventSystem

func NewEventSystem(backend SubscribeBackend) *EventSystem

NewEventSystem creates a new manager that listens for event on the given mux, parses and filters them. It uses the all map to retrieve filter changes. The work loop holds its own index that is used to forward events to filters.

The returned manager has a loop that needs to be stopped with the Stop function or by stopping the given mux.

func (*EventSystem) SubscribeLogs

func (es *EventSystem) SubscribeLogs(crit ethereum.FilterQuery, logs chan []*types.Log) (*Subscription, error)

SubscribeLogs creates a subscription that will write all logs matching the given criteria to the given logs channel. Default value for the from and to block is "latest". If the fromBlock > toBlock an error is returned.

func (*EventSystem) SubscribeNewHeads

func (es *EventSystem) SubscribeNewHeads(headers chan *types.Header) *Subscription

SubscribeNewHeads creates a subscription that writes the header of a block that is imported in the chain.

type Subscribe

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

func (*Subscribe) ChainChan

func (s *Subscribe) ChainChan() chan<- ChainEvent

func (*Subscribe) Err

func (s *Subscribe) Err() <-chan error

func (*Subscribe) SubscribeChainEvent

func (s *Subscribe) SubscribeChainEvent(ch chan<- ChainEvent) event.Subscription

func (*Subscribe) Unsubscribe

func (s *Subscribe) Unsubscribe()

type SubscribeAPI

type SubscribeAPI interface {
	SubscribeChainEvent(chan<- ChainEvent) event.Subscription
}

type SubscribeBackend

type SubscribeBackend interface {
	SubscribeAPI
	ChainChan() chan<- ChainEvent
}

func NewSubscribeBackend

func NewSubscribeBackend(storage storage.Storage) (SubscribeBackend, error)

type Subscription

type Subscription struct {
	ID rpc.ID
	// contains filtered or unexported fields
}

Subscription is created when the client registers itself for a particular event.

func (*Subscription) Err

func (sub *Subscription) Err() <-chan error

Err returns a channel that is closed when unsubscribed.

func (*Subscription) Unsubscribe

func (sub *Subscription) Unsubscribe()

Unsubscribe uninstalls the subscription from the event broadcast loop.

type Type

type Type byte
const (
	// UnknownSubscription indicates an unknown subscription type.
	UnknownSubscription Type = iota
	// LogsSubscription queries for new or removed (chain reorg) logs.
	LogsSubscription
	// BlocksSubscription queries hashes for blocks that are imported.
	BlocksSubscription
	// LastSubscription keeps track of the last index.
	LastIndexSubscription
)

Jump to

Keyboard shortcuts

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