events

package
v1.3.0-test1-nomain Latest Latest
Warning

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

Go to latest
Published: Nov 27, 2023 License: MIT Imports: 14 Imported by: 3

Documentation

Index

Constants

View Source
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 EmitAtxPublished added in v1.0.0

func EmitAtxPublished(
	current, target types.EpochID,
	id types.ATXID,
	wait time.Duration,
)

func EmitBeacon added in v1.0.0

func EmitBeacon(epoch types.EpochID, beacon types.Beacon)

func EmitEligibilities added in v1.0.0

func EmitEligibilities(
	epoch types.EpochID,
	beacon types.Beacon,
	atx types.ATXID,
	activeSetSize uint32,
	eligibilities map[types.LayerID][]types.VotingEligibility,
)

func EmitInitComplete added in v1.0.0

func EmitInitComplete()

func EmitInitFailure added in v1.0.3

func EmitInitFailure(smesher types.NodeID, commitment types.ATXID, err error)

func EmitInitStart added in v1.0.0

func EmitInitStart(smesher types.NodeID, commitment types.ATXID)

func EmitInvalidPostProof added in v1.0.3

func EmitInvalidPostProof()

func EmitOwnMalfeasanceProof added in v1.1.0

func EmitOwnMalfeasanceProof(id types.NodeID, mp *types.MalfeasanceProof)

func EmitPoetWaitProof added in v1.0.0

func EmitPoetWaitProof(publish, target types.EpochID, wait time.Duration)

func EmitPoetWaitRound added in v1.0.0

func EmitPoetWaitRound(current, publish types.EpochID, wait time.Duration)

func EmitPostComplete added in v1.0.0

func EmitPostComplete(challenge []byte)

func EmitPostFailure added in v1.0.0

func EmitPostFailure()

func EmitPostServiceStarted added in v1.3.0

func EmitPostServiceStarted()

func EmitPostServiceStopped added in v1.3.0

func EmitPostServiceStopped()

func EmitPostStart added in v1.0.0

func EmitPostStart(challenge []byte)

func EmitProposal added in v1.0.0

func EmitProposal(layer types.LayerID, proposal types.ProposalID)

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 ReportMalfeasance added in v1.1.0

func ReportMalfeasance(nodeID types.NodeID, mp *types.MalfeasanceProof)

ReportMalfeasance reports a malfeasance proof.

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.

func SubscribeUserEvents added in v1.0.0

func SubscribeUserEvents(opts ...SubOpt) (*BufferedSubscription[UserEvent], *Ring[UserEvent], error)

func ToMalfeasancePB added in v1.1.0

func ToMalfeasancePB(smesher types.NodeID, mp *types.MalfeasanceProof, includeProof bool) *pb.MalfeasanceProof

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.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 EventMalfeasance added in v1.1.0

type EventMalfeasance struct {
	Smesher types.NodeID
	Proof   *types.MalfeasanceProof
}

EventMalfeasance includes the malfeasance proof.

type EventPoetWaitEnd added in v1.0.0

type EventPoetWaitEnd struct {
	Publish types.EpochID `json:"publish"`
	Target  types.EpochID `json:"target"`
	Wait    time.Duration `json:"wait"`
}

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 LayerClock interface {
	AwaitLayer(layerID types.LayerID) <-chan struct{}
	CurrentLayer() types.LayerID
}

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
}

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

type Ring added in v1.0.0

type Ring[T any] struct {
	// contains filtered or unexported fields
}

Ring is an insert only buffer.

func (*Ring[T]) Copy added in v1.0.0

func (r *Ring[T]) Copy() *Ring[T]

func (*Ring[T]) Iterate added in v1.0.0

func (r *Ring[T]) Iterate(iter func(val T) bool)

func (*Ring[T]) Len added in v1.0.0

func (r *Ring[T]) Len() int

type Status added in v1.0.0

type Status struct{}

Status indicates status change event.

type SubOpt added in v1.0.0

type SubOpt func(*subconf)

SubOpt for changing subscribe options.

func WithBuffer added in v1.0.0

func WithBuffer(n int) SubOpt

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 SubscribeMalfeasance added in v1.1.0

func SubscribeMalfeasance() Subscription

SubscribeMalfeasance subscribes malfeasance events.

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.

type UserEvent added in v1.0.0

type UserEvent struct {
	Event *pb.Event
}

Jump to

Keyboard shortcuts

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