Documentation ¶
Index ¶
- Constants
- func CloseEventReporter()
- func EventHook() func(entry zapcore.Entry) error
- func InitializeReporter()
- func ReportAccountUpdate(a types.Address)
- func ReportError(err NodeError)
- func ReportLayerUpdate(layer LayerUpdate)
- func ReportNewActivation(activation *types.VerifiedActivationTx)
- func ReportNewTx(layerID types.LayerID, tx *types.Transaction)
- func ReportNodeStatusUpdate()
- func ReportProposal(status ProposalStatus, proposal *types.Proposal)
- func ReportResult(rst types.TransactionWithResult)
- func ReportRewardReceived(r Reward)
- func ReportTxWithValidity(layerID types.LayerID, tx *types.Transaction, valid bool)
- func SubscribeToLayers(ticker LayerClock)
- type Account
- type ActivationTx
- type BufferedSubscription
- type EventProposal
- type EventReporter
- type LayerClock
- type LayerUpdate
- type NodeError
- type ProposalStatus
- type Reward
- type Status
- type SubOpt
- type Subscription
- type Transaction
- type TxReceipt
Constants ¶
const ( LayerStatusTypeUnknown = iota LayerStatusTypeApproved // approved by Hare LayerStatusTypeConfirmed // confirmed by Tortoise LayerStatusTypeApplied // applied to state )
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 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
ReportAccountUpdate reports an account whose data has been updated.
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.VerifiedActivationTx)
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 ReportResult ¶ added in v1.0.0
func ReportResult(rst types.TransactionWithResult)
ReportResult 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(ticker LayerClock)
SubscribeToLayers is used to track and report automatically every time a new layer is reached.
Types ¶
type ActivationTx ¶ added in v1.0.0
type ActivationTx struct {
*types.VerifiedActivationTx
}
ActivationTx wraps *types.VerifiedActivationTx.
type BufferedSubscription ¶ added in v1.0.0
type BufferedSubscription[T any] struct { // contains filtered or unexported fields }
BufferedSubscription is meant to be used by API subscribers.
Majority of the events are published on the critical consensus path, and they can't block consensus progress if consumer is slow. To account for slow consumer each subscription maintains an internal buffer with specific events, if this buffer overflows consumer should be dropped and stream restarted.
func Subscribe ¶ added in v1.0.0
func Subscribe[T any](opts ...SubOpt) (*BufferedSubscription[T], error)
Subscribe to the objects of type T.
func SubscribeMatched ¶ added in v1.0.0
func SubscribeMatched[T any](matcher func(*T) bool, opts ...SubOpt) (*BufferedSubscription[T], error)
SubscribeMatched subscribes and filters results before adding them to the Out channel.
func (*BufferedSubscription[T]) Close ¶ added in v1.0.0
func (sub *BufferedSubscription[T]) Close()
Close non-blocking close of the subscription.
func (*BufferedSubscription[T]) Full ¶ added in v1.0.0
func (sub *BufferedSubscription[T]) Full() <-chan struct{}
Full is closed if subscriptions buffer overflows.
func (*BufferedSubscription[T]) Out ¶ added in v1.0.0
func (sub *BufferedSubscription[T]) Out() <-chan T
Out is a channel with subscription results.
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 LayerClock ¶ added in v1.0.0
type LayerUpdate ¶ added in v1.0.0
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 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 SubOpt ¶ added in v1.0.0
type SubOpt func(*subconf)
SubOpt for changing subscribe options.
func WithBuffer ¶ added in v1.0.0
WithBuffer changes subscription buffer size.
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 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.