events

package
v0.4.2 Latest Latest
Warning

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

Go to latest
Published: Mar 5, 2020 License: MIT Imports: 3 Imported by: 0

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

	// ETIllegalEvidence indicates a illegal block received.
	ETIllegalBlockEvidence
)

Constants for the type of a notification message.

func (EventType) String added in v0.3.0

func (n EventType) String() string

String returns the EventType in human-readable form.

Jump to

Keyboard shortcuts

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