Documentation ¶
Overview ¶
Package events defines events published by go-spacemsh node using nodes pubsub
Index ¶
- Constants
- func CloseEventPubSub()
- func CloseEventReporter()
- func InitializeEventPubsub(ur string)
- func InitializeEventReporter(url string) error
- func InitializeEventReporterWithOptions(url string, bufsize int) error
- func Publish(event Event)
- func ReportAccountUpdate(a types.Address)
- func ReportAtxCreated(created bool, layer uint64, id string)
- func ReportDoneCreatingBlock(eligible bool, layer uint64, error string)
- func ReportError(err NodeError)
- func ReportNewActivation(activation *types.ActivationTx)
- func ReportNewBlock(blk *types.Block)
- func ReportNewLayer(layer NewLayer)
- func ReportNewTx(tx *types.Transaction, valid TransactionStatus)
- func ReportNodeStatusUpdate()
- func ReportReceipt(r TxReceipt)
- func ReportRewardReceived(r Reward)
- func ReportTxWithValidity(tx *types.Transaction, valid TransactionStatus)
- func ReportValidActivation(activation *types.ActivationTx, valid bool)
- func ReportValidBlock(blockID types.BlockID, valid bool)
- func ReportValidTx(tx *types.Transaction, valid bool)
- func SubscribeToAccounts() chan types.Address
- func SubscribeToActivations() chan *types.ActivationTx
- func SubscribeToErrors() chan NodeError
- func SubscribeToLayerChannel() chan NewLayer
- func SubscribeToLayers(newLayerCh timesync.LayerTimer)
- func SubscribeToReceipts() chan TxReceipt
- func SubscribeToRewards() chan Reward
- func SubscribeToStatus() chan struct{}
- func SubscribeToTxChannel() chan TransactionWithValidity
- func UnsubscribeFromAccounts(subscriptionChannel chan types.Address)
- func UnsubscribeFromActivations(subscriptionChannel chan *types.ActivationTx)
- func UnsubscribeFromErrors(subscriberChannel chan NodeError)
- func UnsubscribeFromLayerChannel(subscriptionChannel chan NewLayer)
- func UnsubscribeFromReceipts(subscriptionChannel chan TxReceipt)
- func UnsubscribeFromRewards(subscriptionChannel chan Reward)
- func UnsubscribeFromStatus(subscriberChannel chan struct{})
- func UnsubscribeFromTxChannel(subscriptionChannel chan TransactionWithValidity)
- type AtxCreated
- type ChannelID
- type DoneCreatingBlock
- type Event
- type EventPublisher
- type EventReporter
- type NewAtx
- type NewBlock
- type NewLayer
- type NewTx
- type NodeError
- type Publisher
- type Reward
- type RewardReceived
- type Subscriber
- type TransactionStatus
- type TransactionWithValidity
- type TxReceipt
- type ValidAtx
- type ValidBlock
- type ValidTx
Constants ¶
const ( LayerStatusTypeUnknown = iota LayerStatusTypeApproved // approved by Hare LayerStatusTypeConfirmed // confirmed by Tortoise )
The status of a layer
Variables ¶
This section is empty.
Functions ¶
func CloseEventPubSub ¶ added in v0.1.16
func CloseEventPubSub()
CloseEventPubSub closes events pubsub and destroys it
func CloseEventReporter ¶ added in v0.1.15
func CloseEventReporter()
CloseEventReporter shuts down the event reporting service and closes open channels
func InitializeEventPubsub ¶
func InitializeEventPubsub(ur string)
InitializeEventPubsub initializes the global pubsub broadcaster server
func InitializeEventReporter ¶ added in v0.1.15
InitializeEventReporter initializes the event reporting interface
func InitializeEventReporterWithOptions ¶ added in v0.1.15
InitializeEventReporterWithOptions 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 ReportAtxCreated ¶ added in v0.1.15
ReportAtxCreated reports a created activation
func ReportDoneCreatingBlock ¶ added in v0.1.15
ReportDoneCreatingBlock reports a created block
func ReportNewActivation ¶ added in v0.1.15
func ReportNewActivation(activation *types.ActivationTx)
ReportNewActivation reports a new activation
func ReportNewBlock ¶ added in v0.1.15
ReportNewBlock reports a new block
func ReportNewLayer ¶ added in v0.1.15
func ReportNewLayer(layer NewLayer)
ReportNewLayer reports a new layer
func ReportNewTx ¶ added in v0.1.15
func ReportNewTx(tx *types.Transaction, valid TransactionStatus)
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 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(tx *types.Transaction, valid TransactionStatus)
ReportTxWithValidity reports a tx along with whether it was just invalidated
func ReportValidActivation ¶ added in v0.1.15
func ReportValidActivation(activation *types.ActivationTx, valid bool)
ReportValidActivation reports a valid activation
func ReportValidBlock ¶ added in v0.1.15
ReportValidBlock reports a block's validity
func ReportValidTx ¶ added in v0.1.15
func ReportValidTx(tx *types.Transaction, valid bool)
ReportValidTx reports a valid transaction
func SubscribeToAccounts ¶ added in v0.1.33
SubscribeToAccounts subscribes a channel to account update events
func SubscribeToActivations ¶ added in v0.1.33
func SubscribeToActivations() chan *types.ActivationTx
SubscribeToActivations allows a process to subscribe to events of activations
func SubscribeToErrors ¶ added in v0.1.33
func SubscribeToErrors() chan NodeError
SubscribeToErrors allows a goroutine to receive a channel for error notifications
func SubscribeToLayerChannel ¶ added in v0.1.33
func SubscribeToLayerChannel() chan NewLayer
SubscribeToLayerChannel allows a process to subscribe to events of newLayers
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.
func SubscribeToReceipts ¶ added in v0.1.33
func SubscribeToReceipts() chan TxReceipt
SubscribeToReceipts allows a process to subscribe to receipt events
func SubscribeToRewards ¶ added in v0.1.33
func SubscribeToRewards() chan Reward
SubscribeToRewards subscribes a channel to rewards events
func SubscribeToStatus ¶ added in v0.1.33
func SubscribeToStatus() chan struct{}
SubscribeToStatus subscribes a channel to receive status updates
func SubscribeToTxChannel ¶ added in v0.1.33
func SubscribeToTxChannel() chan TransactionWithValidity
SubscribeToTxChannel subscribes a process to tx updates
func UnsubscribeFromAccounts ¶ added in v0.1.33
UnsubscribeFromAccounts unsubscribes a channel from accounts events do we need to close the subscriber channel here?
func UnsubscribeFromActivations ¶ added in v0.1.33
func UnsubscribeFromActivations(subscriptionChannel chan *types.ActivationTx)
UnsubscribeFromActivations allows a process to unsubscribe from layer events
func UnsubscribeFromErrors ¶ added in v0.1.33
func UnsubscribeFromErrors(subscriberChannel chan NodeError)
UnsubscribeFromErrors allows a goroutine to unsubscribe from the error channel
func UnsubscribeFromLayerChannel ¶ added in v0.1.33
func UnsubscribeFromLayerChannel(subscriptionChannel chan NewLayer)
UnsubscribeFromLayerChannel allows a process to unsubscribe from layer events
func UnsubscribeFromReceipts ¶ added in v0.1.33
func UnsubscribeFromReceipts(subscriptionChannel chan TxReceipt)
UnsubscribeFromReceipts removes a channel from receipt event notifications
func UnsubscribeFromRewards ¶ added in v0.1.33
func UnsubscribeFromRewards(subscriptionChannel chan Reward)
UnsubscribeFromRewards unsubscribes a channel from rewards events do we need to close the subscriber channel here?
func UnsubscribeFromStatus ¶ added in v0.1.33
func UnsubscribeFromStatus(subscriberChannel chan struct{})
UnsubscribeFromStatus unsubscribes a channel from receiving status updates
func UnsubscribeFromTxChannel ¶ added in v0.1.33
func UnsubscribeFromTxChannel(subscriptionChannel chan TransactionWithValidity)
UnsubscribeFromTxChannel unsubscribes a process from tx updates
Types ¶
type AtxCreated ¶
AtxCreated signals this miner has created an activation transaction
func (AtxCreated) GetChannel ¶
func (AtxCreated) GetChannel() ChannelID
GetChannel gets the message type which means on which this message should be sent
type ChannelID ¶ added in v0.1.11
type ChannelID byte
ChannelID is the ID on which subscribers must register in order to listen to messages on the channel.
type DoneCreatingBlock ¶
DoneCreatingBlock signals that this miner has created a block
func (DoneCreatingBlock) GetChannel ¶
func (DoneCreatingBlock) GetChannel() ChannelID
GetChannel gets the message type which means on which this message should be sent
type Event ¶
type Event interface { // GetChannel returns the channel on which this message will be published. GetChannel() ChannelID }
Event defines the interface that each message sent by the EventPublisher needs to implemet for it to correctly be routed by topic.
type EventPublisher ¶
type EventPublisher struct {
*Publisher
}
EventPublisher is the struct that publishes events to subscribers by topics.
func NewEventPublisher ¶
func NewEventPublisher(eventURL string) (*EventPublisher, error)
NewEventPublisher is a constructor for the event publisher, it received a url string in format of tcp://localhost:56565 to start listening for connections.
func (*EventPublisher) Close ¶
func (p *EventPublisher) Close() error
Close closes the published internal socket
func (*EventPublisher) PublishEvent ¶
func (p *EventPublisher) PublishEvent(event Event) error
PublishEvent publishes the provided event on pubsub infra. It encodes messages using XDR protocol.
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 NewAtx ¶
NewAtx signals that a new ATX has been received
func (NewAtx) GetChannel ¶
GetChannel gets the message type which means on which this message should be sent
type NewBlock ¶
NewBlock is sent when a new block is created by this miner
func (NewBlock) GetChannel ¶
GetChannel gets the message type which means on which this message should be sent
type NewLayer ¶ added in v0.1.15
NewLayer packages up a layer with its status (which a layer does not ordinarily contain)
type NewTx ¶
NewTx signals that a new transaction has been received and not yet validated
func (NewTx) GetChannel ¶
GetChannel gets the message type which means on which this message should be sent
type Publisher ¶
type Publisher struct {
// contains filtered or unexported fields
}
Publisher is a wrapper for mangos pubsub publisher socket
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 RewardReceived ¶
RewardReceived signals reward has been received
func (RewardReceived) GetChannel ¶
func (RewardReceived) GetChannel() ChannelID
GetChannel gets the message type which means on which this message should be sent
type Subscriber ¶
type Subscriber struct {
// contains filtered or unexported fields
}
Subscriber defines the struct of the receiving end of the pubsub messages.
func NewSubscriber ¶
func NewSubscriber(url string) (*Subscriber, error)
NewSubscriber received url string as input on which it will register to receive messages passed by server.
func (*Subscriber) Close ¶
func (sub *Subscriber) Close() error
Close closes the socket which in turn will Close the listener func
func (*Subscriber) StartListening ¶
func (sub *Subscriber) StartListening()
StartListening runs in a go routine and listens to all channels this subscriber is registered to. it then passes the messages received to the appropriate reader channel.
func (*Subscriber) Subscribe ¶
func (sub *Subscriber) Subscribe(topic ChannelID) (chan []byte, error)
Subscribe subscribes to the given topic, returns a channel on which data from the topic is received.
func (*Subscriber) SubscribeToAll ¶
func (sub *Subscriber) SubscribeToAll() (chan []byte, error)
SubscribeToAll subscribes to all available topics.
type TransactionStatus ¶ added in v0.1.40
type TransactionStatus int
TransactionStatus tracks the status of a transaction
const ( TxStatusUnspecified TransactionStatus = iota TxStatusPending TxStatusInvalid TxStatusValid )
These tx statuses track the transaction journey from mempool (pending) to state processing or invalidity
type TransactionWithValidity ¶ added in v0.1.15
type TransactionWithValidity struct { Transaction *types.Transaction Valid TransactionStatus }
TransactionWithValidity wraps a tx with its 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 ValidAtx ¶
ValidAtx signals that an activation transaction with id ID has been validated
func (ValidAtx) GetChannel ¶
GetChannel gets the message type which means on which this message should be sent
type ValidBlock ¶
ValidBlock signals that block with id ID has been validated
func (ValidBlock) GetChannel ¶
func (ValidBlock) GetChannel() ChannelID
GetChannel gets the message type which means on which this message should be sent