filters

package
v3.0.0+incompatible Latest Latest
Warning

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

Go to latest
Published: Oct 15, 2016 License: GPL-3.0 Imports: 16 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

This section is empty.

Functions

This section is empty.

Types

type AccountChange

type AccountChange struct {
	Address, StateAddress []byte
}

type Filter

type Filter struct {
	BlockCallback       func(*types.Block, vm.Logs)
	TransactionCallback func(*types.Transaction)
	LogCallback         func(*vm.Log, bool)
	// contains filtered or unexported fields
}

Filtering interface

func New

func New(db ethdb.Database) *Filter

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

func (*Filter) FilterLogs

func (self *Filter) FilterLogs(logs vm.Logs) vm.Logs

func (*Filter) Find

func (self *Filter) Find() vm.Logs

Run filters logs with the current parameters set

func (*Filter) SetAddresses

func (self *Filter) SetAddresses(addr []common.Address)

func (*Filter) SetBeginBlock

func (self *Filter) SetBeginBlock(begin int64)

Set the earliest and latest block for filtering. -1 = latest block (i.e., the current block) hash = particular hash from-to

func (*Filter) SetEndBlock

func (self *Filter) SetEndBlock(end int64)

func (*Filter) SetTopics

func (self *Filter) SetTopics(topics [][]common.Hash)

type FilterSystem

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

FilterSystem manages filters that filter specific events such as block, transaction and log events. The Filtering system can be used to listen for specific LOG events fired by the EVM (Ethereum Virtual Machine).

func NewFilterSystem

func NewFilterSystem(mux *event.TypeMux) *FilterSystem

NewFilterSystem returns a newly allocated filter manager

func (*FilterSystem) Add

func (fs *FilterSystem) Add(filter *Filter, filterType FilterType) (int, error)

Add adds a filter to the filter manager Expects filterMu to be locked.

func (*FilterSystem) Get

func (fs *FilterSystem) Get(id int) *Filter

func (*FilterSystem) Lock

func (fs *FilterSystem) Lock()

Acquire filter system maps lock, required to force lock acquisition sequence with filterMu acquired first to avoid deadlocks by callbacks

func (*FilterSystem) Remove

func (fs *FilterSystem) Remove(id int)

Remove removes a filter by filter id Expects filterMu to be locked.

func (*FilterSystem) Stop

func (fs *FilterSystem) Stop()

Stop quits the filter loop required for polling events

func (*FilterSystem) Unlock

func (fs *FilterSystem) Unlock()

Release filter system maps lock

type FilterType

type FilterType byte

FilterType determines the type of filter and is used to put the filter in to the correct bucket when added.

const (
	ChainFilter      FilterType = iota // new block events filter
	PendingTxFilter                    // pending transaction filter
	LogFilter                          // new or removed log filter
	PendingLogFilter                   // pending log filter
)

type NewFilterArgs

type NewFilterArgs struct {
	FromBlock rpc.BlockNumber
	ToBlock   rpc.BlockNumber
	Addresses []common.Address
	Topics    [][]common.Hash
}

NewFilterArgs represents a request to create a new filter.

func (*NewFilterArgs) UnmarshalJSON

func (args *NewFilterArgs) UnmarshalJSON(data []byte) error

UnmarshalJSON sets *args fields with given data.

type PublicFilterAPI

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

PublicFilterAPI offers support to create and manage filters. This will allow external clients to retrieve various information related to the Ethereum protocol such als blocks, transactions and logs.

func NewPublicFilterAPI

func NewPublicFilterAPI(chainDb ethdb.Database, mux *event.TypeMux) *PublicFilterAPI

NewPublicFilterAPI returns a new PublicFilterAPI instance.

func (*PublicFilterAPI) GetFilterChanges

func (s *PublicFilterAPI) GetFilterChanges(filterId string) interface{}

GetFilterChanges returns the logs for the filter with the given id since last time is was called. This can be used for polling.

func (*PublicFilterAPI) GetFilterLogs

func (s *PublicFilterAPI) GetFilterLogs(filterId string) []vmlog

GetFilterLogs returns the logs for the filter with the given id.

func (*PublicFilterAPI) GetLogs

func (s *PublicFilterAPI) GetLogs(args NewFilterArgs) []vmlog

GetLogs returns the logs matching the given argument.

func (*PublicFilterAPI) Logs

Logs creates a subscription that fires for all new log that match the given filter criteria.

func (*PublicFilterAPI) NewBlockFilter

func (s *PublicFilterAPI) NewBlockFilter() (string, error)

NewBlockFilter create a new filter that returns blocks that are included into the canonical chain.

func (*PublicFilterAPI) NewFilter

func (s *PublicFilterAPI) NewFilter(args NewFilterArgs) (string, error)

NewFilter creates a new filter and returns the filter id. It can be uses to retrieve logs.

func (*PublicFilterAPI) NewPendingTransactionFilter

func (s *PublicFilterAPI) NewPendingTransactionFilter() (string, error)

NewPendingTransactionFilter creates a filter that returns new pending transactions.

func (*PublicFilterAPI) Stop

func (s *PublicFilterAPI) Stop()

Stop quits the work loop.

func (*PublicFilterAPI) UninstallFilter

func (s *PublicFilterAPI) UninstallFilter(filterId string) bool

UninstallFilter removes the filter with the given filter id.

Jump to

Keyboard shortcuts

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