filters

package
v1.0.9 Latest Latest
Warning

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

Go to latest
Published: Sep 7, 2020 License: GPL-3.0, GPL-3.0 Imports: 10 Imported by: 0

Documentation

Overview

Package filters implements an ethereum filtering system for block, transactions and log events.

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrInvalidSubscriptionID = errors.New("invalid id")
)

Functions

This section is empty.

Types

type Backend

type Backend interface {
	ChainDb() ptndb.Database
	EventMux() *event.TypeMux
	HeaderByNumber(ctx context.Context, blockNr rpc.BlockNumber) (*modules.Header, error)
	//GetReceipts(ctx context.Context, blockHash common.Hash) (modules.Receipts, error)
	//GetLogs(ctx context.Context, blockHash common.Hash) ([][]*types.Log, error)
	SubscribeTxPreEvent(chan<- modules.TxPreEvent) event.Subscription

	BloomStatus() (uint64, uint64)
	ServiceFilter(ctx context.Context, session *bloombits.MatcherSession)
}

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(mux *event.TypeMux, backend Backend, lightMode bool) *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) SubscribeNewHeads

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

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

func (*EventSystem) SubscribePendingTxEvents

func (es *EventSystem) SubscribePendingTxEvents(hashes chan common.Hash) *Subscription

SubscribePendingTxEvents creates a subscription that writes transaction hashes for transactions that enter the transaction pool.

type Filter

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

Filter can be used to retrieve and filter logs.

func New

func New(backend Backend, begin, end int64, addresses []common.Address, topics [][]common.Hash) *Filter

New creates a new filter which uses a bloom filter on blocks to figure out whether a particular block is interesting or not.

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

Type determines the kind of filter and is used to put the filter in to the correct bucket when added.

const (
	// UnknownSubscription indicates an unknown subscription type
	UnknownSubscription Type = iota
	// LogsSubscription queries for new or removed (chain reorg) logs
	LogsSubscription
	// PendingLogsSubscription queries for logs in pending blocks
	PendingLogsSubscription
	// MinedAndPendingLogsSubscription queries for logs in mined and pending blocks.
	MinedAndPendingLogsSubscription
	// PendingTransactionsSubscription queries tx hashes for pending
	// transactions entering the pending state
	PendingTransactionsSubscription
	// 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