Documentation
¶
Index ¶
- Variables
- type FilterCond
- type FilterOptions
- type FilterQuery
- func FilterFrom(from ethkit.Address) FilterQuery
- func FilterLogContract(contractAddress ethkit.Address) FilterQuery
- func FilterLogTopic(eventTopicHash ethkit.Hash) FilterQuery
- func FilterLogs(logFn func([]*types.Log) bool) FilterQuery
- func FilterTo(to ethkit.Address) FilterQuery
- func FilterTxnHash(txnHash ethkit.Hash) FilterQuery
- type Filterer
- type Options
- type Receipt
- func (r *Receipt) AsMessage() (*core.Message, error)
- func (r *Receipt) BlockHash() ethkit.Hash
- func (r *Receipt) BlockNumber() *big.Int
- func (r *Receipt) Bloom() types.Bloom
- func (r *Receipt) CumulativeGasUsed() uint64
- func (r *Receipt) DeployedContractAddress() common.Address
- func (r *Receipt) EffectiveGasPrice() *big.Int
- func (r *Receipt) FilterID() uint64
- func (r *Receipt) From() common.Address
- func (r *Receipt) GasUsed() uint64
- func (r *Receipt) Logs() []*types.Log
- func (r *Receipt) Receipt() *types.Receipt
- func (r *Receipt) Root() []byte
- func (r *Receipt) Status() uint64
- func (r *Receipt) To() common.Address
- func (r *Receipt) TransactionHash() ethkit.Hash
- func (r *Receipt) TransactionIndex() uint
- func (r *Receipt) Type() uint8
- type ReceiptsListener
- func (l *ReceiptsListener) FetchTransactionReceipt(ctx context.Context, txnHash common.Hash, optMaxBlockWait ...int) (*Receipt, error)
- func (l *ReceiptsListener) FetchTransactionReceiptWithFilter(ctx context.Context, filter FilterQuery, optFilterFinalize ...bool) (*Receipt, WaitReceiptFinalityFunc, error)
- func (l *ReceiptsListener) FetchTransactionReceiptWithFinality(ctx context.Context, txnHash common.Hash, optMaxBlockWait ...int) (*Receipt, WaitReceiptFinalityFunc, error)
- func (l *ReceiptsListener) IsRunning() bool
- func (l *ReceiptsListener) LatestBlockNum() *big.Int
- func (l *ReceiptsListener) NumSubscribers() int
- func (l *ReceiptsListener) PurgeHistory()
- func (l *ReceiptsListener) RPCProvider() ethrpc.Interface
- func (l *ReceiptsListener) Run(ctx context.Context) error
- func (l *ReceiptsListener) Stop()
- func (l *ReceiptsListener) Subscribe(filterQueries ...FilterQuery) Subscription
- type Subscription
- type WaitReceiptFinalityFunc
Constants ¶
This section is empty.
Variables ¶
View Source
var ( ErrFilterMatch = errors.New("ethreceipts: filter match fail") ErrFilterCond = errors.New("ethreceipts: missing filter condition") ErrFilterExhausted = errors.New("ethreceipts: filter exhausted after maxWait blocks") ErrSubscriptionClosed = errors.New("ethreceipts: subscription closed") )
View Source
var DefaultOptions = Options{ MaxConcurrentFetchReceiptWorkers: 100, MaxConcurrentFilterWorkers: 200, MaxConcurrentSearchOnChainWorkers: 15, PastReceiptsCacheSize: 5_000, NumBlocksToFinality: 0, FilterMaxWaitNumBlocks: 0, Alerter: util.NoopAlerter(), }
Functions ¶
This section is empty.
Types ¶
type FilterCond ¶
type FilterOptions ¶
type FilterOptions struct {
// ID is a caller-supplied label, not a unique registration identity.
ID uint64
// Finalize requests a final receipt after the mined receipt.
Finalize bool
// LimitOne stops matching after one mined receipt and preserves queued finality.
LimitOne bool
// SearchCache searches the monitor's retained blocks when the filter is registered.
SearchCache bool
// QueryOnChainTxnHash will query the chain for the txn hash at the start
// of a filter subscription. This is only useful when used in combination with
// TxnHash filter cond, to search for past transactions which may have been
// mined before the filter was created.
QueryOnChainTxnHash bool
// QueryOnChain optionally fetches a receipt when the filter is registered.
QueryOnChain func(context.Context) (*types.Receipt, error)
// MaxWait limits blocks without a match before matching is exhausted.
// Receipts already queued for finality are still finalized.
//
// nil : use the ReceiptsListener option FilterMaxWaitNumBlocks value as the default
// <0 : use ReceiptsListener option NumBlocksToFinality * 2
// 0 : option is disabled, and has no limit on wait. filters need to be manually unsubscribed
// N : a specified number of blocks without a match before exhaustion
MaxWait *int
}
type FilterQuery ¶
type FilterQuery interface {
ID(uint64) FilterQuery
Finalize(bool) FilterQuery
LimitOne(bool) FilterQuery
SearchCache(bool) FilterQuery
QueryOnChainTxnHash(bool) FilterQuery
QueryOnChain(func(context.Context) (*types.Receipt, error)) FilterQuery
MaxWait(int) FilterQuery
// Deprecated: use QueryOnChainTxnHash instead.
SearchOnChain(bool) FilterQuery
}
func FilterFrom ¶
func FilterFrom(from ethkit.Address) FilterQuery
Filter the transaction payload for "from" address.
func FilterLogContract ¶
func FilterLogContract(contractAddress ethkit.Address) FilterQuery
Filter the logs of a transaction and search for an event log from a specific contract address.
func FilterLogTopic ¶
func FilterLogTopic(eventTopicHash ethkit.Hash) FilterQuery
Filter the log topics for a transaction
func FilterLogs ¶ added in v1.17.6
func FilterLogs(logFn func([]*types.Log) bool) FilterQuery
Filter logs of a transaction
func FilterTo ¶
func FilterTo(to ethkit.Address) FilterQuery
Filter the transaction payload for "to" address.
func FilterTxnHash ¶
func FilterTxnHash(txnHash ethkit.Hash) FilterQuery
Filter the transaction payload for specific txn "hash"
type Filterer ¶
type Filterer interface {
FilterQuery
FilterID() uint64
Options() FilterOptions
Cond() FilterCond
Match(ctx context.Context, receipt Receipt) (bool, error)
StartBlockNum() uint64
LastMatchBlockNum() uint64
Exhausted() <-chan struct{}
}
type Options ¶
type Options struct {
// MaxConcurrentFetchReceiptWorkers limits concurrent receipt RPC requests.
MaxConcurrentFetchReceiptWorkers int
// MaxConcurrentFilterWorkers limits concurrent block and filter processing.
MaxConcurrentFilterWorkers int
// MaxConcurrentSearchOnChainWorkers limits on-chain searches per subscriber.
MaxConcurrentSearchOnChainWorkers int
// PastReceiptsCacheSize limits the number of cached receipts.
PastReceiptsCacheSize int
// NumBlocksToFinality is the number of blocks after mining required for finality.
// Values <= 0 select the network's finality policy when Run starts.
NumBlocksToFinality int
// FilterMaxWaitNumBlocks sets the default block wait between filter matches.
// Zero disables the limit. Individual filters can override it with MaxWait.
FilterMaxWaitNumBlocks int
// Alerter receives listener and subscriber alerts.
Alerter util.Alerter
}
type Receipt ¶
type Receipt struct {
Filter Filterer // reference to filter which triggered this event
Final bool // flags that this receipt is finalized
Reorged bool // chain reorged / removed the txn
// contains filtered or unexported fields
}
func (*Receipt) BlockNumber ¶
func (*Receipt) CumulativeGasUsed ¶
func (*Receipt) DeployedContractAddress ¶
DeployedContractAddress returns the address if this receipt is related to a contract deployment.
func (*Receipt) EffectiveGasPrice ¶
func (*Receipt) TransactionHash ¶
func (*Receipt) TransactionIndex ¶
type ReceiptsListener ¶ added in v1.18.0
type ReceiptsListener struct {
// contains filtered or unexported fields
}
func NewReceiptsListener ¶ added in v1.18.0
func NewReceiptsListener(log *slog.Logger, provider ethrpc.Interface, monitor *ethmonitor.Monitor, options ...Options) (*ReceiptsListener, error)
func (*ReceiptsListener) FetchTransactionReceipt ¶ added in v1.18.0
func (*ReceiptsListener) FetchTransactionReceiptWithFilter ¶ added in v1.18.0
func (l *ReceiptsListener) FetchTransactionReceiptWithFilter(ctx context.Context, filter FilterQuery, optFilterFinalize ...bool) (*Receipt, WaitReceiptFinalityFunc, error)
func (*ReceiptsListener) FetchTransactionReceiptWithFinality ¶ added in v1.39.0
func (l *ReceiptsListener) FetchTransactionReceiptWithFinality(ctx context.Context, txnHash common.Hash, optMaxBlockWait ...int) (*Receipt, WaitReceiptFinalityFunc, error)
func (*ReceiptsListener) IsRunning ¶ added in v1.18.0
func (l *ReceiptsListener) IsRunning() bool
func (*ReceiptsListener) LatestBlockNum ¶ added in v1.39.0
func (l *ReceiptsListener) LatestBlockNum() *big.Int
func (*ReceiptsListener) NumSubscribers ¶ added in v1.19.4
func (l *ReceiptsListener) NumSubscribers() int
func (*ReceiptsListener) PurgeHistory ¶ added in v1.18.0
func (l *ReceiptsListener) PurgeHistory()
func (*ReceiptsListener) RPCProvider ¶ added in v1.39.0
func (l *ReceiptsListener) RPCProvider() ethrpc.Interface
func (*ReceiptsListener) Run ¶ added in v1.18.0
func (l *ReceiptsListener) Run(ctx context.Context) error
func (*ReceiptsListener) Stop ¶ added in v1.18.0
func (l *ReceiptsListener) Stop()
func (*ReceiptsListener) Subscribe ¶ added in v1.18.0
func (l *ReceiptsListener) Subscribe(filterQueries ...FilterQuery) Subscription
type Subscription ¶
type Subscription interface {
TransactionReceipt() <-chan Receipt
Done() <-chan struct{}
// Unsubscribe closes the subscription. Repeated and concurrent calls are safe.
Unsubscribe()
Filters() []Filterer
AddFilter(filters ...FilterQuery)
// RemoveFilter removes the first matching active registration, or its queued
// finality owner if inactive. Comparable filters retain Go equality. Otherwise
// callback-bearing values of the same type use a stable nonnil Exhausted signal
// as base identity. Values sharing a base are aliases; distinct callbacks need
// distinct bases or pointer identities for independent removal. Values without
// a stable signal should be registered as pointers for individual removal.
RemoveFilter(filter Filterer)
ClearFilters()
}
Click to show internal directories.
Click to hide internal directories.