Documentation
¶
Index ¶
- Constants
- Variables
- func NewMsgFromCbor(msgType uint, data []byte) (protocol.Message, error)
- type BlockRangeRequestFunc
- type BlockRequestFunc
- type BlockTxsRequestFunc
- type CallbackContext
- type Client
- func (c *Client) BlockRangeRequest(start pcommon.Point, end pcommon.Point) ([]protocol.Message, error)
- func (c *Client) BlockRequest(slot uint64, hash []byte) (protocol.Message, error)
- func (c *Client) BlockTxsRequest(slot uint64, hash []byte, txBitmap [8]byte) (protocol.Message, error)
- func (c *Client) Start()
- func (c *Client) Stop() error
- func (c *Client) VotesRequest(voteIds []MsgVotesRequestVoteId) (protocol.Message, error)
- type Config
- type LeiosFetch
- type LeiosFetchOptionFunc
- func WithBlockRangeRequestFunc(blockRangeRequestFunc BlockRangeRequestFunc) LeiosFetchOptionFunc
- func WithBlockRequestFunc(blockRequestFunc BlockRequestFunc) LeiosFetchOptionFunc
- func WithBlockTxsRequestFunc(blockTxsRequestFunc BlockTxsRequestFunc) LeiosFetchOptionFunc
- func WithTimeout(timeout time.Duration) LeiosFetchOptionFunc
- func WithVotesRequestFunc(votesRequestFunc VotesRequestFunc) LeiosFetchOptionFunc
- type MsgBlock
- type MsgBlockRangeRequest
- type MsgBlockRequest
- type MsgBlockTxs
- type MsgBlockTxsRequest
- type MsgDone
- type MsgLastBlockAndTxsInRange
- type MsgNextBlockAndTxsInRange
- type MsgVotes
- type MsgVotesRequest
- type MsgVotesRequestVoteId
- type Server
- type VotesRequestFunc
Constants ¶
const ( ProtocolName = "leios-fetch" ProtocolId uint16 = 19 )
const ( MessageTypeBlockRequest = 0 MessageTypeBlock = 1 MessageTypeBlockTxsRequest = 2 MessageTypeBlockTxs = 3 MessageTypeVotesRequest = 4 MessageTypeVotes = 5 MessageTypeBlockRangeRequest = 6 MessageTypeLastBlockAndTxsInRange = 7 MessageTypeNextBlockAndTxsInRange = 8 MessageTypeDone = 9 )
NOTE: these are dummy message IDs and will probably need to be changed
Variables ¶
var ( StateIdle = protocol.NewState(1, "Idle") StateBlock = protocol.NewState(2, "Block") StateBlockTxs = protocol.NewState(3, "BlockTxs") StateVotes = protocol.NewState(4, "Votes") StateBlockRange = protocol.NewState(5, "BlockRange") StateDone = protocol.NewState(6, "Done") )
var StateMap = protocol.StateMap{ StateIdle: protocol.StateMapEntry{ Agency: protocol.AgencyClient, Transitions: []protocol.StateTransition{ { MsgType: MessageTypeBlockRequest, NewState: StateBlock, }, { MsgType: MessageTypeBlockTxsRequest, NewState: StateBlockTxs, }, { MsgType: MessageTypeVotesRequest, NewState: StateVotes, }, { MsgType: MessageTypeBlockRangeRequest, NewState: StateBlockRange, }, { MsgType: MessageTypeDone, NewState: StateDone, }, }, }, StateBlock: protocol.StateMapEntry{ Agency: protocol.AgencyServer, Transitions: []protocol.StateTransition{ { MsgType: MessageTypeBlock, NewState: StateIdle, }, }, }, StateBlockTxs: protocol.StateMapEntry{ Agency: protocol.AgencyServer, Transitions: []protocol.StateTransition{ { MsgType: MessageTypeBlockTxs, NewState: StateIdle, }, }, }, StateVotes: protocol.StateMapEntry{ Agency: protocol.AgencyServer, Transitions: []protocol.StateTransition{ { MsgType: MessageTypeVotes, NewState: StateIdle, }, }, }, StateBlockRange: protocol.StateMapEntry{ Agency: protocol.AgencyServer, Transitions: []protocol.StateTransition{ { MsgType: MessageTypeNextBlockAndTxsInRange, NewState: StateBlockRange, }, { MsgType: MessageTypeLastBlockAndTxsInRange, NewState: StateIdle, }, }, }, StateDone: protocol.StateMapEntry{ Agency: protocol.AgencyNone, }, }
Functions ¶
Types ¶
type BlockRangeRequestFunc ¶
Callback function types
type BlockRequestFunc ¶
Callback function types
type BlockTxsRequestFunc ¶
Callback function types
type CallbackContext ¶
type CallbackContext struct {
ConnectionId connection.ConnectionId
Client *Client
Server *Server
}
Callback context
type Client ¶
func (*Client) BlockRangeRequest ¶
func (c *Client) BlockRangeRequest(start pcommon.Point, end pcommon.Point) ([]protocol.Message, error)
BlockRangeRequest fetches a range of EBs and their TXs that are certified by RBs within the provided range. This function will block until all EBs and TXs in the requested range have been received
func (*Client) BlockRequest ¶
BlockRequest fetches the requested EB identified by the slot and Leios hash
func (*Client) BlockTxsRequest ¶
func (c *Client) BlockTxsRequest(slot uint64, hash []byte, txBitmap [8]byte) (protocol.Message, error)
BlockTxsRequest fetches the requested TXs identified by the slot, Leios hash, and TX bitmap
func (*Client) VotesRequest ¶
func (c *Client) VotesRequest(voteIds []MsgVotesRequestVoteId) (protocol.Message, error)
VotesRequest fetches the requested votes
type Config ¶
type Config struct {
BlockRequestFunc BlockRequestFunc
BlockTxsRequestFunc BlockTxsRequestFunc
VotesRequestFunc VotesRequestFunc
BlockRangeRequestFunc BlockRangeRequestFunc
Timeout time.Duration
}
func NewConfig ¶
func NewConfig(options ...LeiosFetchOptionFunc) Config
type LeiosFetch ¶
func New ¶
func New(protoOptions protocol.ProtocolOptions, cfg *Config) *LeiosFetch
type LeiosFetchOptionFunc ¶
type LeiosFetchOptionFunc func(*Config)
func WithBlockRangeRequestFunc ¶
func WithBlockRangeRequestFunc(blockRangeRequestFunc BlockRangeRequestFunc) LeiosFetchOptionFunc
WithBlockRangeRequestFunc specifies a callback function for BlockRangeRequest messages when acting as a server. The callback is expected to return an error and start an async process to generate and send LastBlockAndTxsInRange and NextBlockAndTxsInRange messages that satisfy the requested range
func WithBlockRequestFunc ¶
func WithBlockRequestFunc(blockRequestFunc BlockRequestFunc) LeiosFetchOptionFunc
WithBlockRequestFunc specifies a callback function for BlockRequest messages when acting as a server. The callback is expected to return the proper response message and an error
func WithBlockTxsRequestFunc ¶
func WithBlockTxsRequestFunc(blockTxsRequestFunc BlockTxsRequestFunc) LeiosFetchOptionFunc
WithBlockTxsRequestFunc specifies a callback function for BlockTxsRequest messages when acting as a server. The callback is expected to return the proper response message and an error
func WithTimeout ¶
func WithTimeout(timeout time.Duration) LeiosFetchOptionFunc
func WithVotesRequestFunc ¶
func WithVotesRequestFunc(votesRequestFunc VotesRequestFunc) LeiosFetchOptionFunc
WithVotesRequestFunc specifies a callback function for VotesRequest messages when acting as a server. The callback is expected to return the proper response message and an error
type MsgBlock ¶
type MsgBlock struct {
protocol.MessageBase
BlockRaw cbor.RawMessage
}
func NewMsgBlock ¶
func NewMsgBlock(block cbor.RawMessage) *MsgBlock
type MsgBlockRangeRequest ¶
func NewMsgBlockRangeRequest ¶
func NewMsgBlockRangeRequest(start pcommon.Point, end pcommon.Point) *MsgBlockRangeRequest
type MsgBlockRequest ¶
type MsgBlockRequest struct {
protocol.MessageBase
Slot uint64
Hash []byte
}
func NewMsgBlockRequest ¶
func NewMsgBlockRequest(slot uint64, hash []byte) *MsgBlockRequest
type MsgBlockTxs ¶
type MsgBlockTxs struct {
protocol.MessageBase
TxsRaw []cbor.RawMessage
}
func NewMsgBlockTxs ¶
func NewMsgBlockTxs(txs []cbor.RawMessage) *MsgBlockTxs
type MsgBlockTxsRequest ¶
type MsgBlockTxsRequest struct {
protocol.MessageBase
Slot uint64
Hash []byte
TxBitmap [8]byte
}
func NewMsgBlockTxsRequest ¶
func NewMsgBlockTxsRequest(slot uint64, hash []byte, txBitmap [8]byte) *MsgBlockTxsRequest
type MsgDone ¶
type MsgDone struct {
protocol.MessageBase
}
func NewMsgDone ¶
func NewMsgDone() *MsgDone
type MsgLastBlockAndTxsInRange ¶
type MsgLastBlockAndTxsInRange struct {
protocol.MessageBase
BlockRaw cbor.RawMessage
TxsRaw []cbor.RawMessage
}
func NewMsgLastBlockAndTxsInRange ¶
func NewMsgLastBlockAndTxsInRange(block cbor.RawMessage, txs []cbor.RawMessage) *MsgLastBlockAndTxsInRange
type MsgNextBlockAndTxsInRange ¶
type MsgNextBlockAndTxsInRange struct {
protocol.MessageBase
BlockRaw cbor.RawMessage
TxsRaw []cbor.RawMessage
}
func NewMsgNextBlockAndTxsInRange ¶
func NewMsgNextBlockAndTxsInRange(block cbor.RawMessage, txs []cbor.RawMessage) *MsgNextBlockAndTxsInRange
type MsgVotes ¶
type MsgVotes struct {
protocol.MessageBase
VotesRaw []cbor.RawMessage
}
func NewMsgVotes ¶
func NewMsgVotes(votes []cbor.RawMessage) *MsgVotes
type MsgVotesRequest ¶
type MsgVotesRequest struct {
protocol.MessageBase
VoteIds []MsgVotesRequestVoteId
}
func NewMsgVotesRequest ¶
func NewMsgVotesRequest(voteIds []MsgVotesRequestVoteId) *MsgVotesRequest
type MsgVotesRequestVoteId ¶
type MsgVotesRequestVoteId struct {
cbor.StructAsArray
Slot uint64
VoteIssuerId []byte
}
type VotesRequestFunc ¶
type VotesRequestFunc func(CallbackContext, []MsgVotesRequestVoteId) (protocol.Message, error)
Callback function types