leiosnotify

package
v0.136.0 Latest Latest
Warning

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

Go to latest
Published: Oct 13, 2025 License: Apache-2.0 Imports: 7 Imported by: 0

Documentation

Index

Constants

View Source
const (
	ProtocolName        = "leios-notify"
	ProtocolId   uint16 = 998 // NOTE: this is a dummy value and will need to be changed
)
View Source
const (
	MessageTypeNotificationRequestNext = 0
	MessageTypeBlockAnnouncement       = 1
	MessageTypeBlockOffer              = 2
	MessageTypeBlockTxsOffer           = 3
	MessageTypeVotesOffer              = 4
	MessageTypeDone                    = 5
)

NOTE: these are dummy message IDs and will probably need to be changed

Variables

View Source
var (
	StateIdle = protocol.NewState(1, "Idle")
	StateBusy = protocol.NewState(2, "Busy")
	StateDone = protocol.NewState(4, "Done")
)
View Source
var StateMap = protocol.StateMap{
	StateIdle: protocol.StateMapEntry{
		Agency: protocol.AgencyClient,
		Transitions: []protocol.StateTransition{
			{
				MsgType:  MessageTypeNotificationRequestNext,
				NewState: StateBusy,
			},
			{
				MsgType:  MessageTypeDone,
				NewState: StateDone,
			},
		},
	},
	StateBusy: protocol.StateMapEntry{
		Agency: protocol.AgencyServer,
		Transitions: []protocol.StateTransition{
			{
				MsgType:  MessageTypeBlockAnnouncement,
				NewState: StateIdle,
			},
			{
				MsgType:  MessageTypeBlockOffer,
				NewState: StateIdle,
			},
			{
				MsgType:  MessageTypeBlockTxsOffer,
				NewState: StateIdle,
			},
			{
				MsgType:  MessageTypeVotesOffer,
				NewState: StateIdle,
			},
		},
	},
	StateDone: protocol.StateMapEntry{
		Agency: protocol.AgencyNone,
	},
}

Functions

func NewMsgFromCbor

func NewMsgFromCbor(msgType uint, data []byte) (protocol.Message, error)

Types

type CallbackContext

type CallbackContext struct {
	ConnectionId connection.ConnectionId
	Client       *Client
	Server       *Server
}

Callback context

type Client

type Client struct {
	*protocol.Protocol
	// contains filtered or unexported fields
}

func NewClient

func NewClient(protoOptions protocol.ProtocolOptions, cfg *Config) *Client

func (*Client) RequestNext

func (c *Client) RequestNext() (protocol.Message, error)

RequestNext fetches the next available notification. This function will block until a notification is received from the peer.

func (*Client) Start

func (c *Client) Start()

func (*Client) Stop

func (c *Client) Stop() error

type Config

type Config struct {
	RequestNextFunc RequestNextFunc
	Timeout         time.Duration
}

func NewConfig

func NewConfig(options ...LeiosNotifyOptionFunc) Config

type LeiosNotify

type LeiosNotify struct {
	Client *Client
	Server *Server
}

func New

func New(protoOptions protocol.ProtocolOptions, cfg *Config) *LeiosNotify

type LeiosNotifyOptionFunc

type LeiosNotifyOptionFunc func(*Config)

func WithRequestNextFunc

func WithRequestNextFunc(
	requestNextFunc RequestNextFunc,
) LeiosNotifyOptionFunc

func WithTimeout

func WithTimeout(timeout time.Duration) LeiosNotifyOptionFunc

type MsgBlockAnnouncement

type MsgBlockAnnouncement struct {
	protocol.MessageBase
	BlockHeaderRaw cbor.RawMessage
}

func NewMsgBlockAnnouncement

func NewMsgBlockAnnouncement(
	blockHeader cbor.RawMessage,
) *MsgBlockAnnouncement

type MsgBlockOffer

type MsgBlockOffer struct {
	protocol.MessageBase
	Slot uint64
	Hash []byte
}

func NewMsgBlockOffer

func NewMsgBlockOffer(slot uint64, hash []byte) *MsgBlockOffer

type MsgBlockTxsOffer

type MsgBlockTxsOffer struct {
	protocol.MessageBase
	Slot uint64
	Hash []byte
}

func NewMsgBlockTxsOffer

func NewMsgBlockTxsOffer(slot uint64, hash []byte) *MsgBlockTxsOffer

type MsgDone

type MsgDone struct {
	protocol.MessageBase
}

func NewMsgDone

func NewMsgDone() *MsgDone

type MsgNotificationRequestNext

type MsgNotificationRequestNext struct {
	protocol.MessageBase
}

func NewMsgNotificationRequestNext

func NewMsgNotificationRequestNext() *MsgNotificationRequestNext

type MsgVotesOffer

type MsgVotesOffer struct {
	protocol.MessageBase
	Votes []MsgVotesOfferVote
}

func NewMsgVotesOffer

func NewMsgVotesOffer(votes []MsgVotesOfferVote) *MsgVotesOffer

type MsgVotesOfferVote

type MsgVotesOfferVote struct {
	cbor.StructAsArray
	Slot         uint64
	VoteIssuerId []byte
}

type RequestNextFunc

type RequestNextFunc func(CallbackContext) (protocol.Message, error)

Callback function types

type Server

type Server struct {
	*protocol.Protocol
	// contains filtered or unexported fields
}

func NewServer

func NewServer(protoOptions protocol.ProtocolOptions, cfg *Config) *Server

Jump to

Keyboard shortcuts

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