event

package
v0.0.0-...-27a0780 Latest Latest
Warning

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

Go to latest
Published: Mar 23, 2020 License: LGPL-3.0 Imports: 2 Imported by: 0

Documentation

Index

Constants

View Source
const (
	DownloaderStartEvent   = 0
	DownloaderDoneEvent    = 1
	DownloaderFailedEvent  = 2
	ChallengedTxEvent      = 3
	ChallengedTxAfterEvent = 4
)

block downloader event

Variables

View Source
var BlockDownloaderEventManager = NewEventManager()

BlockDownloaderEventManager block download event

View Source
var BlockMinedEventManager = NewEventManager()

BlockMinedEventManager represents the event that a new block is mined

View Source
var ChainHeaderChangedEventMananger = NewEventManager()

ChainHeaderChangedEventMananger represents the event that chain header is changed

View Source
var ChallengedTxAfterEventManager = NewEventManager()
View Source
var ChallengedTxEventManager = NewEventManager()

ChallengedTxEventManager once challenged tx exit in txpool, need to revert and pack the tx into the first new block

View Source
var DebtsInsertedEventManager = NewEventManager()
View Source
var EmptyEvent interface{}

EmptyEvent is an empty event

View Source
var TransactionInsertedEventManager = NewEventManager()

TransactionInsertedEventManager represents the event that a new transaction is inserted into txpool

Functions

This section is empty.

Types

type Event

type Event interface {
}

Event is the interface of events

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.

Jump to

Keyboard shortcuts

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