ethreceipts

package
v1.17.3 Latest Latest
Warning

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

Go to latest
Published: Jan 4, 2023 License: LGPL-3.0, MIT Imports: 20 Imported by: 3

Documentation

Index

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: 50,
	MaxConcurrentFilterWorkers:       20,
	PastReceiptsCacheSize:            5_000,
	NumBlocksToFinality:              0,
	FilterMaxWaitNumBlocks:           0,
}

Functions

This section is empty.

Types

type FilterCond

type FilterCond struct {
	TxnHash  *ethkit.Hash
	From     *ethkit.Address
	To       *ethkit.Address
	LogTopic *ethkit.Hash // event signature topic hash
	Log      func(*types.Log) bool
}

type FilterOptions

type FilterOptions struct {
	// ..
	ID uint64

	// ..
	Finalize bool

	// .
	LimitOne bool

	// ..
	SearchCache bool

	// SearchOnChain will search for txn hash on-chain. This is only useful
	// when used in combination with TxnHash filter cond.
	SearchOnChain bool

	// MaxWait filter option waits some number of blocks without a filter match after
	// which point will auto-unsubscribe the filter. This is useful to help automatically
	// remove filters which likely won't come up.
	//
	// nil : use the ReceiptListener option FilterMaxWaitNumBlocks value as the default
	// -1  : set value to ReceiptListener option NumFinality * 3
	// 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 unsusbcribe
	MaxWait *int
}

type FilterQuery

type FilterQuery interface {
	ID(uint64) FilterQuery
	Finalize(bool) FilterQuery
	LimitOne(bool) FilterQuery
	SearchCache(bool) FilterQuery
	SearchOnChain(bool) FilterQuery
	MaxWait(int) FilterQuery
}

func FilterFrom

func FilterFrom(from ethkit.Address) FilterQuery

func FilterLog

func FilterLog(logFn func(*types.Log) bool) FilterQuery

func FilterLogContract

func FilterLogContract(contractAddress ethkit.Address) FilterQuery

func FilterLogTopic

func FilterLogTopic(eventTopicHash ethkit.Hash) FilterQuery

func FilterTo

func FilterTo(to ethkit.Address) FilterQuery

func FilterTxnHash

func FilterTxnHash(txnHash ethkit.Hash) FilterQuery

type Filterer

type Filterer interface {
	FilterQuery

	FilterID() uint64
	Options() FilterOptions
	Cond() FilterCond

	Match(ctx context.Context, receipt Receipt) (bool, error)
	LastMatchBlockNum() uint64
	Exhausted() <-chan struct{}
}

type Options

type Options struct {
	// ..
	MaxConcurrentFetchReceiptWorkers int

	// ..
	MaxConcurrentFilterWorkers int

	// ..
	PastReceiptsCacheSize int

	// ..
	NumBlocksToFinality int

	// FilterMaxWaitNumBlocks is the maximum amount of blocks a filter will wait between getting
	// a receipt filter match, before the filter will unsubscribe itself and stop listening.
	// This value may be overriden by setting FilterCond#MaxListenNumBlocks on per-filter basis.
	//
	// NOTE:
	// * value of -1 will use NumBlocksToFinality*2
	// * value of 0 will set no limit, so filter will always listen [default]
	// * value of N will set the N number of blocks without results before unsubscribing between iterations
	FilterMaxWaitNumBlocks int
}

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) BlockHash

func (r *Receipt) BlockHash() ethkit.Hash

func (*Receipt) BlockNumber

func (r *Receipt) BlockNumber() *big.Int

func (*Receipt) Bloom

func (r *Receipt) Bloom() types.Bloom

func (*Receipt) CumulativeGasUsed

func (r *Receipt) CumulativeGasUsed() uint64

func (*Receipt) DeployedContractAddress

func (r *Receipt) DeployedContractAddress() common.Address

DeployedContractAddress returns the address if this receipt is related to a contract deployment.

func (*Receipt) EffectiveGasPrice

func (r *Receipt) EffectiveGasPrice() *big.Int

func (*Receipt) FilterID

func (r *Receipt) FilterID() uint64

func (*Receipt) From

func (r *Receipt) From() common.Address

func (*Receipt) GasUsed

func (r *Receipt) GasUsed() uint64

func (*Receipt) Logs

func (r *Receipt) Logs() []*types.Log

func (*Receipt) Receipt

func (r *Receipt) Receipt() *types.Receipt

func (*Receipt) Root

func (r *Receipt) Root() []byte

func (*Receipt) Status

func (r *Receipt) Status() uint64

func (*Receipt) To

func (r *Receipt) To() common.Address

func (*Receipt) TransactionHash

func (r *Receipt) TransactionHash() ethkit.Hash

func (*Receipt) TransactionIndex

func (r *Receipt) TransactionIndex() uint

func (*Receipt) Type

func (r *Receipt) Type() uint8

type ReceiptListener

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

func NewReceiptListener

func NewReceiptListener(log logger.Logger, provider *ethrpc.Provider, monitor *ethmonitor.Monitor, options ...Options) (*ReceiptListener, error)

func (*ReceiptListener) FetchTransactionReceipt

func (l *ReceiptListener) FetchTransactionReceipt(ctx context.Context, txnHash common.Hash, optMaxBlockWait ...int) (*Receipt, WaitReceiptFinalityFunc, error)

func (*ReceiptListener) FetchTransactionReceiptWithFilter

func (l *ReceiptListener) FetchTransactionReceiptWithFilter(ctx context.Context, filter FilterQuery) (*Receipt, WaitReceiptFinalityFunc, error)

func (*ReceiptListener) IsRunning

func (l *ReceiptListener) IsRunning() bool

func (*ReceiptListener) PurgeHistory

func (l *ReceiptListener) PurgeHistory()

func (*ReceiptListener) Run

func (l *ReceiptListener) Run(ctx context.Context) error

func (*ReceiptListener) Stop

func (l *ReceiptListener) Stop()

func (*ReceiptListener) Subscribe

func (l *ReceiptListener) Subscribe(filterQueries ...FilterQuery) Subscription

type Subscription

type Subscription interface {
	TransactionReceipt() <-chan Receipt
	Done() <-chan struct{}
	Unsubscribe()

	Filters() []Filterer
	AddFilter(filters ...FilterQuery)
	RemoveFilter(filter Filterer)
	ClearFilters()
}

type WaitReceiptFinalityFunc

type WaitReceiptFinalityFunc func(ctx context.Context) (*Receipt, error)

Jump to

Keyboard shortcuts

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