Documentation
¶
Index ¶
- Constants
- Variables
- func NewMsgFromCbor(msgType uint, data []byte) (protocol.Message, error)
- type CallbackContext
- type Client
- type Config
- type LeiosNotify
- type LeiosNotifyOptionFunc
- type MsgBlockAnnouncement
- type MsgBlockOffer
- type MsgBlockTxsOffer
- type MsgDone
- type MsgNotificationRequestNext
- type MsgVotesOffer
- type MsgVotesOfferVote
- type RequestNextFunc
- type Server
Constants ¶
View Source
const ( ProtocolName = "leios-notify" ProtocolId uint16 = 18 )
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(3, "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 ¶
Types ¶
type CallbackContext ¶
type CallbackContext struct {
ConnectionId connection.ConnectionId
Client *Client
Server *Server
}
Callback context
type Client ¶
func (*Client) RequestNext ¶
RequestNext fetches the next available notification. This function will block until a notification is received from the peer.
type Config ¶
type Config struct {
RequestNextFunc RequestNextFunc
Timeout time.Duration
}
func NewConfig ¶
func NewConfig(options ...LeiosNotifyOptionFunc) Config
type LeiosNotify ¶
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
Click to show internal directories.
Click to hide internal directories.