Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type EVMWatcher ¶
type EVMWatcher struct {
// contains filtered or unexported fields
}
EVMWatcher watches multiple contracts of one chain over a single connection, so that the whole chain shares one consistent block progress.
func NewEVMWatcher ¶
func NewEVMWatcher(chainName, wssURL string, watcherData []WatcherData, storage StorageInterface, event EventInterface, options ...Option) *EVMWatcher
func (*EVMWatcher) AddWatcher ¶
func (e *EVMWatcher) AddWatcher(watcherData WatcherData) error
func (*EVMWatcher) GetWatcherData ¶
func (e *EVMWatcher) GetWatcherData() []WatcherData
func (*EVMWatcher) RemoveWatcher ¶
func (e *EVMWatcher) RemoveWatcher(watcherData WatcherData) error
func (*EVMWatcher) Start ¶
func (e *EVMWatcher) Start() error
func (*EVMWatcher) Stop ¶
func (e *EVMWatcher) Stop()
type Event ¶
type Event struct {
ContractAddress common.Address
EventName string
BlockNumber uint64
BlockHash common.Hash
TxHash common.Hash
TxIndex uint
LogIndex uint
Args map[string]any
// Removed is true when the log has been reverted by a chain reorg.
Removed bool
Raw types.Log
}
Event is the decoded contract event delivered through EventInterface.
type EventInterface ¶
type EventInterface interface {
// OnEvent is called with the chain the event belongs to, so that one
// implementation can serve several chains.
OnEvent(chainName string, event *Event) error
}
监听到事件之后向外通知的接口
type Option ¶
type Option func(*EVMWatcher)
func WithConfirmations ¶ added in v0.0.2
WithConfirmations delays delivery and watermark until a block is N blocks behind the chain head. 0 (default) keeps the current immediate-delivery behavior.
func WithMaxBlockRange ¶
WithMaxBlockRange sets the block span of one eth_getLogs call, it is shrunk automatically when the provider rejects the range.
func WithPollInterval ¶ added in v0.0.2
WithPollInterval sets the poll interval used when confirmations > 0.
func WithRequestInterval ¶
WithRequestInterval sets the minimum gap between two RPC calls.
type StorageInterface ¶
type WatcherData ¶
type WatcherData struct {
ContractAddress string
ContractABI string
// EventNames is the watched event name list, empty means every event in the ABI.
EventNames []string
}
WatcherData describes one contract and the events watched on it.