Documentation ¶
Overview ¶
package filters implements an ethereum filtering system for block, transactions and log events.
Index ¶
- type AccountChange
- type Filter
- type FilterSystem
- type FilterType
- type NewFilterArgs
- type PublicFilterAPI
- func (s *PublicFilterAPI) GetFilterChanges(filterId string) interface{}
- func (s *PublicFilterAPI) GetFilterLogs(filterId string) []vmlog
- func (s *PublicFilterAPI) GetLogs(args NewFilterArgs) []vmlog
- func (s *PublicFilterAPI) Logs(ctx context.Context, args NewFilterArgs) (rpc.Subscription, error)
- func (s *PublicFilterAPI) NewBlockFilter() (string, error)
- func (s *PublicFilterAPI) NewFilter(args NewFilterArgs) (string, error)
- func (s *PublicFilterAPI) NewPendingTransactionFilter() (string, error)
- func (s *PublicFilterAPI) Stop()
- func (s *PublicFilterAPI) UninstallFilter(filterId string) bool
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type AccountChange ¶ added in v1.3.1
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 ¶ added in v1.3.1
Create a new filter which uses a bloom filter on blocks to figure out whether a particular block is interesting or not.
func (*Filter) SetAddresses ¶ added in v1.3.1
func (*Filter) SetBeginBlock ¶ added in v1.3.1
Set the earliest and latest block for filtering. -1 = latest block (i.e., the current block) hash = particular hash from-to
func (*Filter) SetEndBlock ¶ added in v1.3.1
type FilterSystem ¶ added in v1.3.1
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 ¶ added in v1.3.1
func NewFilterSystem(mux *event.TypeMux) *FilterSystem
NewFilterSystem returns a newly allocated filter manager
func (*FilterSystem) Add ¶ added in v1.3.1
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 ¶ added in v1.3.1
func (fs *FilterSystem) Get(id int) *Filter
func (*FilterSystem) Lock ¶ added in v1.4.11
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 ¶ added in v1.3.1
func (fs *FilterSystem) Remove(id int)
Remove removes a filter by filter id Expects filterMu to be locked.
func (*FilterSystem) Stop ¶ added in v1.3.1
func (fs *FilterSystem) Stop()
Stop quits the filter loop required for polling events
func (*FilterSystem) Unlock ¶ added in v1.4.11
func (fs *FilterSystem) Unlock()
Release filter system maps lock
type FilterType ¶ added in v1.4.0
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 ¶ added in v1.4.0
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 ¶ added in v1.4.0
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 ¶
func (s *PublicFilterAPI) Logs(ctx context.Context, args NewFilterArgs) (rpc.Subscription, error)
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 ¶ added in v1.4.0
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.