Documentation ¶
Index ¶
- func NewEventStr(contractAddr common.Address, eventName string) string
- type CallbackID
- type Config
- type Contract
- type Deadline
- type DeadlineQueue
- type Event
- type Service
- func (s *Service) Close()
- func (s *Service) GetCurrentBlockNumber() *big.Int
- func (s *Service) Init()
- func (s *Service) Monitor(cfg *Config, callback func(CallbackID, types.Log)) (CallbackID, error)
- func (s *Service) MonitorEvent(e Event, reset bool) (CallbackID, error)
- func (s *Service) RegisterDeadline(d Deadline) CallbackID
- func (s *Service) RemoveDeadline(id CallbackID)
- func (s *Service) RemoveEvent(id CallbackID)
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type CallbackID ¶
type CallbackID uint64
CallbackID is the unique callback ID for deadlines and events
type Config ¶
type Config struct { EventName string Contract Contract StartBlock, EndBlock *big.Int Reset bool CheckInterval uint64 BlockDelay uint64 // if zero, use service.blockDelay by default }
Config is used by external callers to pass in info, will be converted to Event for internal use Reason not use Event directly: Event is more like internal struct most fields are from previous MonitorService Monitor func args CheckInterval means to check log for event every CheckInterval x WatchService.polling if 0 or not set, defaultCheckInterval (1) will be used
type DeadlineQueue ¶
DeadlineQueue is the priority queue for deadlines
func (DeadlineQueue) Len ¶
func (dq DeadlineQueue) Len() int
func (DeadlineQueue) Less ¶
func (dq DeadlineQueue) Less(i, j int) bool
func (*DeadlineQueue) Pop ¶
func (dq *DeadlineQueue) Pop() (popped interface{})
func (*DeadlineQueue) Push ¶
func (dq *DeadlineQueue) Push(x interface{})
func (DeadlineQueue) Swap ¶
func (dq DeadlineQueue) Swap(i, j int)
func (*DeadlineQueue) Top ¶
func (dq *DeadlineQueue) Top() (top interface{})
type Event ¶
type Event struct { Addr common.Address RawAbi string Name string WatchName string StartBlock *big.Int EndBlock *big.Int BlockDelay uint64 CheckInterval uint64 Callback func(CallbackID, types.Log) // contains filtered or unexported fields }
Event is the metadata for an event
type Service ¶
type Service struct {
// contains filtered or unexported fields
}
Service struct stores service parameters and registered deadlines and events
func NewService ¶
func NewService( watch *watcher.WatchService, blockDelay uint64, enabled bool) *Service
NewService starts a new monitor service. If "enabled" is false, event monitoring will be disabled.
func (*Service) Close ¶
func (s *Service) Close()
Close only set events map to empty map so all monitorEvent will exit due to isEventRemoved is true
func (*Service) GetCurrentBlockNumber ¶
func (*Service) Monitor ¶
func (s *Service) Monitor(cfg *Config, callback func(CallbackID, types.Log)) (CallbackID, error)
func (*Service) MonitorEvent ¶
func (s *Service) MonitorEvent(e Event, reset bool) (CallbackID, error)
func (*Service) RegisterDeadline ¶
func (s *Service) RegisterDeadline(d Deadline) CallbackID
RegisterDeadline registers the deadline and returns the ID
func (*Service) RemoveDeadline ¶
func (s *Service) RemoveDeadline(id CallbackID)
RemoveDeadline removes a deadline from the monitor
func (*Service) RemoveEvent ¶
func (s *Service) RemoveEvent(id CallbackID)
RemoveEvent removes an event from the monitor