func (TortoiseBeaconCalculated) GetChannel() ChannelID {
	return EventCalculatedTortoiseBeacon
}
GetChannel gets the message type which means on which this message should be sent.
package events
import (
	"fmt"
	"github.com/spacemeshos/go-spacemesh/common/types"
	"github.com/spacemeshos/go-spacemesh/log"
)
const (
	EventNewBlock ChannelID = 1 + iota
	EventBlockValid
	EventNewAtx
	EventAtxValid
	EventNewTx
	EventTxValid
	EventRewardReceived
	EventCreatedBlock
	EventCreatedAtx
	EventCalculatedTortoiseBeacon
)
var publisher *EventPublisher
func Publish(event Event) {
	if publisher != nil {
		if err := publisher.PublishEvent(event); err != nil {
			log.Error("pubsub error: %v", err)
		}
	}
}
func InitializeEventPubsub(ur string) error {
	var err error
	publisher, err = NewEventPublisher(ur)
	return err
}
func CloseEventPubSub() {
	if publisher != nil {
		publisher.Close()
		publisher = nil
	}
}
type EventPublisher struct {
	*Publisher
}
type Event interface {
	GetChannel() ChannelID
}
func NewEventPublisher(eventURL string) (*EventPublisher, error) {
	p, err := newPublisher(eventURL)
	if err != nil {
		return nil, err
	}
	return &EventPublisher{p}, nil
}
func (p *EventPublisher) PublishEvent(event Event) error {
	bytes, err := types.InterfaceToBytes(event)
	if err != nil {
		return fmt.Errorf("serialize: %w", err)
	}
	if err := p.publish(event.GetChannel(), bytes); err != nil {
		return fmt.Errorf("publish: %w", err)
	}
	return nil
}
func (p *EventPublisher) Close() error {
	if err := p.sock.Close(); err != nil {
		return fmt.Errorf("close socket: %w", err)
	}
	return nil
}
type NewBlock struct {
	ID    string
	Layer uint32
	Atx   string
}
func (NewBlock) GetChannel() ChannelID {
	return EventNewBlock
}
type DoneCreatingBlock struct {
	Eligible bool
	Layer    uint32
	Error    string
}
func (DoneCreatingBlock) GetChannel() ChannelID {
	return EventCreatedBlock
}
type ValidBlock struct {
	ID    string
	Valid bool
}
func (ValidBlock) GetChannel() ChannelID {
	return EventBlockValid
}
type NewAtx struct {
	ID      string
	EpochID uint32
}
func (NewAtx) GetChannel() ChannelID {
	return EventNewAtx
}
type ValidAtx struct {
	ID    string
	Valid bool
}
func (ValidAtx) GetChannel() ChannelID {
	return EventAtxValid
}
type NewTx struct {
	ID          string
	Origin      string
	Destination string
	Amount      uint64
	Fee         uint64
}
func (NewTx) GetChannel() ChannelID {
	return EventNewTx
}
type ValidTx struct {
	ID    string
	Valid bool
}
func (ValidTx) GetChannel() ChannelID {
	return EventTxValid
}
type RewardReceived struct {
	Coinbase  string
	Amount    uint64
	SmesherID []byte
}
func (RewardReceived) GetChannel() ChannelID {
	return EventRewardReceived
}
type AtxCreated struct {
	Created bool
	ID      string
	Epoch   uint32
}
func (AtxCreated) GetChannel() ChannelID {
	return EventCreatedAtx
}
type TortoiseBeaconCalculated struct {
	Epoch  types.EpochID
	Beacon string
}