events

package
v0.2.14-beta.0 Latest Latest
Warning

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

Go to latest
Published: Mar 23, 2022 License: MIT Imports: 9 Imported by: 3

Documentation

Index

Constants

View Source
const (
	LayerStatusTypeUnknown   = iota
	LayerStatusTypeApproved  // approved by Hare
	LayerStatusTypeConfirmed // confirmed by Tortoise
)

The status of a layer TODO: this list is woefully inadequate and does not map to reality. See https://github.com/spacemeshos/api/issues/144.

Variables

This section is empty.

Functions

func CloseEventReporter added in v0.1.15

func CloseEventReporter()

CloseEventReporter shuts down the event reporting service and closes open channels.

func EventHook added in v1.0.0

func EventHook() func(entry zapcore.Entry) error

EventHook returns hook for logger.

func InitializeReporter added in v1.0.0

func InitializeReporter()

InitializeReporter initializes the event reporting interface with a nonzero channel buffer. This is useful for testing, where we want reporting to block.

func ReportAccountUpdate added in v0.1.15

func ReportAccountUpdate(a types.Address)

ReportAccountUpdate reports an account whose data has been updated.

func ReportError added in v0.1.15

func ReportError(err NodeError)

ReportError reports an error.

func ReportLayerUpdate added in v1.0.0

func ReportLayerUpdate(layer LayerUpdate)

ReportLayerUpdate reports a new layer, or an update to an existing layer.

func ReportNewActivation added in v0.1.15

func ReportNewActivation(activation *types.ActivationTx)

ReportNewActivation reports a new activation.

func ReportNewTx added in v0.1.15

func ReportNewTx(layerID types.LayerID, tx *types.Transaction)

ReportNewTx dispatches incoming events to the reporter singleton.

func ReportNodeStatusUpdate added in v0.1.15

func ReportNodeStatusUpdate()

ReportNodeStatusUpdate reports an update to the node status. It just pings the listener to notify them that there is an update; the listener is responsible for fetching the new status details. This is because status contains disparate information coming from different services, and the listener already knows how to gather that information so there is no point in duplicating that logic here. Note: There is some overlap with channelLayer here, as a new latest or verified layer should be sent over that channel as well. However, that happens inside the Mesh, at the source. It doesn't currently happen here because the status update includes only a layer ID, not full layer data, and the Reporter currently has no way to retrieve full layer data.

func ReportProposal added in v1.0.0

func ReportProposal(status ProposalStatus, proposal *types.Proposal)

ReportProposal reports a proposal.

func ReportReceipt added in v0.1.15

func ReportReceipt(r TxReceipt)

ReportReceipt reports creation or receipt of a new tx receipt.

func ReportRewardReceived added in v0.1.15

func ReportRewardReceived(r Reward)

ReportRewardReceived reports a new reward.

func ReportTxWithValidity added in v0.1.15

func ReportTxWithValidity(layerID types.LayerID, tx *types.Transaction, valid bool)

ReportTxWithValidity reports a tx along with whether it was just invalidated.

func SubscribeToLayers added in v0.1.15

func SubscribeToLayers(newLayerCh timesync.LayerTimer)

SubscribeToLayers is used to track and report automatically every time a new layer is reached.

Types

type Account added in v1.0.0

type Account struct {
	types.Address
}

Account wraps account address.

type ActivationTx added in v1.0.0

type ActivationTx struct {
	*types.ActivationTx
}

ActivationTx wraps *types.ActivationTx.

type EventProposal added in v1.0.0

type EventProposal struct {
	Status   ProposalStatus
	Proposal *types.Proposal
}

EventProposal includes proposal and proposal status.

type EventReporter added in v0.1.15

type EventReporter struct {
	// contains filtered or unexported fields
}

EventReporter is the struct that receives incoming events and dispatches them.

type LayerUpdate added in v1.0.0

type LayerUpdate struct {
	LayerID types.LayerID
	Status  int
}

LayerUpdate packages up a layer with its status (which a layer does not ordinarily contain).

func (LayerUpdate) Field added in v1.0.0

func (nl LayerUpdate) Field() log.Field

Field returns a log field. Implements the LoggableField interface.

type NodeError added in v0.1.15

type NodeError struct {
	Msg   string
	Trace string
	Level zapcore.Level
}

NodeError represents an internal error to be reported.

type ProposalStatus added in v1.0.0

type ProposalStatus int

ProposalStatus is a type for proposal status.

const (
	// ProposalCreated is a status of the proposal that was created.
	ProposalCreated ProposalStatus = iota
	// ProposalIncluded is a status of the proposal when it is included into the block.
	ProposalIncluded
)

func (ProposalStatus) String added in v1.0.0

func (s ProposalStatus) String() string

type Reward added in v0.1.15

type Reward struct {
	Layer       types.LayerID
	Total       uint64
	LayerReward uint64
	Coinbase    types.Address
	// TODO: We don't currently have a way to get the Layer Computed.
	// See https://github.com/spacemeshos/go-spacemesh/issues/2275
	// LayerComputed
	Smesher types.NodeID
}

Reward represents a reward object with extra data needed by the API.

type Status added in v1.0.0

type Status struct{}

Status indicates status change event.

type Subscription added in v1.0.0

type Subscription = event.Subscription

Subscription is a subscription to events. Consumer must be aware that publish will block if subsription is not read fast enough.

func SubcribeProposals added in v1.0.0

func SubcribeProposals() Subscription

SubcribeProposals subscribes to the proposals.

func SubscribeAccount added in v1.0.0

func SubscribeAccount() Subscription

SubscribeAccount subscribes to account data updates.

func SubscribeActivations added in v1.0.0

func SubscribeActivations() Subscription

SubscribeActivations subscribes to activations.

func SubscribeErrors added in v1.0.0

func SubscribeErrors() Subscription

SubscribeErrors subscribes to node errors.

func SubscribeLayers added in v1.0.0

func SubscribeLayers() Subscription

SubscribeLayers subscribes to all layer data.

func SubscribeReceipts

func SubscribeReceipts() Subscription

SubscribeReceipts subscribes to receipts.

func SubscribeRewards added in v1.0.0

func SubscribeRewards() Subscription

SubscribeRewards subscribes to rewards.

func SubscribeStatus added in v1.0.0

func SubscribeStatus() Subscription

SubscribeStatus subscribes to node status messages.

func SubscribeTxs added in v1.0.0

func SubscribeTxs() Subscription

SubscribeTxs subscribes to new transactions.

type Transaction added in v1.0.0

type Transaction struct {
	Transaction *types.Transaction
	LayerID     types.LayerID
	Valid       bool
}

Transaction wraps a tx with its layer ID and validity info.

type TxReceipt added in v0.1.15

type TxReceipt struct {
	ID      types.TransactionID
	Result  int
	GasUsed uint64
	Fee     uint64
	Layer   types.LayerID
	Index   uint32
	Address types.Address
}

TxReceipt represents a transaction receipt.

Jump to

Keyboard shortcuts

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