Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Notify ¶ added in v0.3.0
func Notify(typ EventType, data interface{})
Notify sends a notification with the passed type and data if the caller requested notifications by providing a callback function in the call to New.
func Subscribe ¶ added in v0.3.0
func Subscribe(callback EventCallback)
Subscribe to block chain notifications. Registers a callback to be executed when various events take place. See the documentation on Event and EventType for details on the types and contents of notifications.
Types ¶
type Event ¶
type Event struct { Type EventType Data interface{} }
Event defines notification that is sent to the caller via the callback function provided during the call to New and consists of a notification type as well as associated data that depends on the type as follows:
- ETBlockAccepted: *types.Block
- ETBlockConnected: *types.Block
- ETBlockDisconnected: *types.Block
- ETTransactionAccepted: *types.Transaction
type EventCallback ¶ added in v0.3.0
type EventCallback func(*Event)
EventCallback is used for a caller to provide a callback for notifications about various chain events.
type EventType ¶
type EventType int
EventType represents the type of a event message.
const ( // ETBlockAccepted indicates a new block received. ETBlockAccepted EventType = iota // ETBlockConnected indicates the associated block was connected to the // main chain. ETBlockConnected // ETBlockDisconnected indicates the associated block was disconnected // from the main chain. ETBlockDisconnected // ETTransactionAccepted indicates the associated transaction was accepted // into transaction mem pool. ETTransactionAccepted // ETNewBlockReceived indicates a new block was received. ETNewBlockReceived // ETConfirmAccepted indicates a block confirmed message received. ETConfirmAccepted // ETDirectPeersChanged indicates direct peers has changed. ETDirectPeersChanged // ETBlockConfirmAccepted indicates a block with confirm was accepted // into the block chain. Note that this does not necessarily mean it // was added to the main chain. For that, use ETBlockConnected. ETBlockConfirmAccepted // ETBlockProcessed indicates the status of DPOS and CR has changed. ETBlockProcessed // ETIllegalEvidence indicates a illegal block received. ETIllegalBlockEvidence //ETNextTurnDPOSInfo indicates need add an NextTurnDPOSInfo to tx pool ETAppendTxToTxPool //ETAppendTxToTxPoolWithoutRelay indicates need add an NextTurnDPOSInfo //to tx pool but do not relay. ETAppendTxToTxPoolWithoutRelay //ETCRCChangeCommittee indicates need add crc changed committee ETCRCChangeCommittee //ETSmallCrossChainNeedRelay indicates that need to relay some small cross //chain transaction ETSmallCrossChainNeedRelay )
Constants for the type of a notification message.