Documentation
¶
Index ¶
- func FilterLogs(logs []*ethtypes.Log, fromBlock, toBlock *big.Int, addresses []common.Address, ...) []*ethtypes.Log
- type Backend
- type BloomIV
- type Filter
- type FilterAPI
- type PublicFilterAPI
- func (api *PublicFilterAPI) GetFilterChanges(id rpc.ID) (interface{}, error)
- func (api *PublicFilterAPI) GetFilterLogs(ctx context.Context, id rpc.ID) ([]*ethtypes.Log, error)
- func (api *PublicFilterAPI) GetLogs(ctx context.Context, crit filters.FilterCriteria) ([]*ethtypes.Log, error)
- func (api *PublicFilterAPI) NewBlockFilter() rpc.ID
- func (api *PublicFilterAPI) NewFilter(criteria filters.FilterCriteria) (rpc.ID, error)
- func (api *PublicFilterAPI) NewPendingTransactionFilter() rpc.ID
- func (api *PublicFilterAPI) UninstallFilter(id rpc.ID) bool
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func FilterLogs ¶
func FilterLogs(logs []*ethtypes.Log, fromBlock, toBlock *big.Int, addresses []common.Address, topics [][]common.Hash) []*ethtypes.Log
FilterLogs creates a slice of logs matching the given criteria. [] -> anything [A] -> A in first position of log topics, anything after [null, B] -> anything in first position, B in second position [A, B] -> A in first position and B in second position [[A, B], [A, B]] -> A or B in first position, A or B in second position
Types ¶
type Backend ¶
type Backend interface { GetBlockByNumber(blockNum types.BlockNumber, fullTx bool) (map[string]interface{}, error) HeaderByNumber(blockNum types.BlockNumber) (*ethtypes.Header, error) HeaderByHash(blockHash common.Hash) (*ethtypes.Header, error) CometBlockByHash(hash common.Hash) (*coretypes.ResultBlock, error) CometBlockResultByNumber(height *int64) (*coretypes.ResultBlockResults, error) GetLogs(blockHash common.Hash) ([][]*ethtypes.Log, error) GetLogsByHeight(*int64) ([][]*ethtypes.Log, error) BlockBloom(blockRes *coretypes.ResultBlockResults) (ethtypes.Bloom, error) BloomStatus() (uint64, uint64) RPCFilterCap() int32 RPCLogsCap() int32 RPCBlockRangeCap() int32 }
Backend defines the methods requided by the PublicFilterAPI backend
type BloomIV ¶
BloomIV represents the bit indexes and value inside the bloom filter that belong to some key.
type Filter ¶
type Filter struct {
// contains filtered or unexported fields
}
Filter can be used to retrieve and filter logs.
func NewBlockFilter ¶
NewBlockFilter creates a new filter which directly inspects the contents of a block to figure out whether it is interesting or not.
type FilterAPI ¶
type FilterAPI interface { NewPendingTransactionFilter() rpc.ID NewBlockFilter() rpc.ID NewFilter(criteria filters.FilterCriteria) (rpc.ID, error) GetFilterChanges(id rpc.ID) (interface{}, error) GetFilterLogs(ctx context.Context, id rpc.ID) ([]*ethtypes.Log, error) UninstallFilter(id rpc.ID) bool GetLogs(ctx context.Context, crit filters.FilterCriteria) ([]*ethtypes.Log, error) }
FilterAPI gathers
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 as blocks, transactions and logs.
func NewPublicAPI ¶
func NewPublicAPI( logger log.Logger, clientCtx client.Context, stream *stream.RPCStream, backend Backend, ) *PublicFilterAPI
NewPublicAPI returns a new PublicFilterAPI instance.
func NewPublicAPIWithDeadline ¶ added in v0.3.0
func NewPublicAPIWithDeadline( logger log.Logger, clientCtx client.Context, stream *stream.RPCStream, backend Backend, deadline time.Duration, ) *PublicFilterAPI
NewPublicAPIWithDeadline returns a new PublicFilterAPI instance with the given deadline.
func (*PublicFilterAPI) GetFilterChanges ¶
func (api *PublicFilterAPI) GetFilterChanges(id rpc.ID) (interface{}, error)
GetFilterChanges returns the logs for the filter with the given id since last time it was called. This can be used for polling.
For pending transaction and block filters the result is []common.Hash. (pending)Log filters return []Log.
https://github.com/ethereum/wiki/wiki/JSON-RPC#eth_getfilterchanges
func (*PublicFilterAPI) GetFilterLogs ¶
GetFilterLogs returns the logs for the filter with the given id. If the filter could not be found an empty array of logs is returned.
https://github.com/ethereum/wiki/wiki/JSON-RPC#eth_getfilterlogs
func (*PublicFilterAPI) GetLogs ¶
func (api *PublicFilterAPI) GetLogs(ctx context.Context, crit filters.FilterCriteria) ([]*ethtypes.Log, error)
GetLogs returns logs matching the given argument that are stored within the state.
func (*PublicFilterAPI) NewBlockFilter ¶
func (api *PublicFilterAPI) NewBlockFilter() rpc.ID
NewBlockFilter creates a filter that fetches blocks that are imported into the chain. It is part of the filter package since polling goes with eth_getFilterChanges.
https://github.com/ethereum/wiki/wiki/JSON-RPC#eth_newblockfilter
func (*PublicFilterAPI) NewFilter ¶
func (api *PublicFilterAPI) NewFilter(criteria filters.FilterCriteria) (rpc.ID, error)
NewFilter creates a new filter and returns the filter id. It can be used to retrieve logs when the state changes. This method cannot be used to fetch logs that are already stored in the state.
Default criteria for the from and to block are "latest". Using "latest" as block number will return logs for mined blocks. Using "pending" as block number returns logs for not yet mined (pending) blocks. In case logs are removed (chain reorg) previously returned logs are returned again but with the removed property set to true.
In case "fromBlock" > "toBlock" an error is returned.
https://github.com/ethereum/wiki/wiki/JSON-RPC#eth_newfilter
func (*PublicFilterAPI) NewPendingTransactionFilter ¶
func (api *PublicFilterAPI) NewPendingTransactionFilter() rpc.ID
NewPendingTransactionFilter creates a filter that fetches pending transaction hashes as transactions enter the pending state.
It is part of the filter package because this filter can be used through the `eth_getFilterChanges` polling method that is also used for log filters.
https://github.com/ethereum/wiki/wiki/JSON-RPC#eth_newPendingTransactionFilter
func (*PublicFilterAPI) UninstallFilter ¶
func (api *PublicFilterAPI) UninstallFilter(id rpc.ID) bool
UninstallFilter removes the filter with the given filter id.
https://github.com/ethereum/wiki/wiki/JSON-RPC#eth_uninstallfilter