Documentation ¶
Index ¶
- Constants
- Variables
- type Event
- type EventHandleMethod
- type EventManager
- func (h *EventManager) AddAsyncListener(callback EventHandleMethod)
- func (h *EventManager) AddAsyncOnceListener(callback EventHandleMethod)
- func (h *EventManager) AddListener(callback EventHandleMethod)
- func (h *EventManager) AddOnceListener(callback EventHandleMethod)
- func (h *EventManager) Fire(e Event)
- func (h *EventManager) RemoveListener(callback EventHandleMethod)
Constants ¶
const ( DownloaderStartEvent = 0 DownloaderDoneEvent = 1 DownloaderFailedEvent = 2 ChallengedTxEvent = 3 ChallengedTxAfterEvent = 4 )
block downloader event
Variables ¶
var BlockDownloaderEventManager = NewEventManager()
BlockDownloaderEventManager block download event
var BlockMinedEventManager = NewEventManager()
BlockMinedEventManager represents the event that a new block is mined
var ChainHeaderChangedEventMananger = NewEventManager()
ChainHeaderChangedEventMananger represents the event that chain header is changed
var ChallengedTxAfterEventManager = NewEventManager()
var ChallengedTxEventManager = NewEventManager()
ChallengedTxEventManager once challenged tx exit in txpool, need to revert and pack the tx into the first new block
var DebtsInsertedEventManager = NewEventManager()
var EmptyEvent interface{}
EmptyEvent is an empty event
var TransactionInsertedEventManager = NewEventManager()
TransactionInsertedEventManager represents the event that a new transaction is inserted into txpool
Functions ¶
This section is empty.
Types ¶
type EventHandleMethod ¶
type EventHandleMethod func(e Event)
EventHandleMethod represents an event handler
type EventManager ¶
type EventManager struct {
// contains filtered or unexported fields
}
EventManager is an interface which defines the event manager behaviors Note that it is thread safe
func NewEventManager ¶
func NewEventManager() *EventManager
NewEventManager creates a new instance of event manager
func (*EventManager) AddAsyncListener ¶
func (h *EventManager) AddAsyncListener(callback EventHandleMethod)
AddAsyncListener registers a listener which runs async
func (*EventManager) AddAsyncOnceListener ¶
func (h *EventManager) AddAsyncOnceListener(callback EventHandleMethod)
AddAsyncOnceListener registers a listener which only runs once and async
func (*EventManager) AddListener ¶
func (h *EventManager) AddListener(callback EventHandleMethod)
AddListener registers a listener. If there is already a same listener (same method pointer), we will not add it
func (*EventManager) AddOnceListener ¶
func (h *EventManager) AddOnceListener(callback EventHandleMethod)
AddOnceListener registers a listener which only runs once
func (*EventManager) Fire ¶
func (h *EventManager) Fire(e Event)
Fire triggers all listeners with the specified event and removes listeners which run only once.
func (*EventManager) RemoveListener ¶
func (h *EventManager) RemoveListener(callback EventHandleMethod)
RemoveListener removes the registered event listener for given event name.