Documentation ¶
Overview ¶
Package filters implements an ethereum filtering system for block, transactions and log events.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Backend ¶
type Backend = api.FilterService
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 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) 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 *motypes.Header) *Subscription
SubscribeNewHeads creates a subscription that writes the header of a block that is imported in the chain.
type PublicFilterAPI ¶
type PublicFilterAPI interface { GetFilterChanges(id rpc.ID) (interface{}, error) GetFilterLogs(id rpc.ID) ([]*gethtypes.Log, error) GetLogs(crit gethfilters.FilterCriteria) ([]*gethtypes.Log, error) NewBlockFilter() rpc.ID NewFilter(crit gethfilters.FilterCriteria) (rpc.ID, error) UninstallFilter(id rpc.ID) bool NewHeads(ctx context.Context) (*rpc.Subscription, error) Logs(ctx context.Context, crit gethfilters.FilterCriteria) (*rpc.Subscription, error) }
func NewAPI ¶
func NewAPI(backend mapi.BackendService, logger log.Logger) PublicFilterAPI
type Subscription ¶
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 )