leiosfetch

package
v0.137.0 Latest Latest
Warning

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

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

Documentation

Index

Constants

View Source
const (
	ProtocolName        = "leios-fetch"
	ProtocolId   uint16 = 19
)
View Source
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

View Source
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")
)

Functions

func NewMsgFromCbor

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

Types

type BlockRangeRequestFunc

type BlockRangeRequestFunc func(CallbackContext, pcommon.Point, pcommon.Point) error

Callback function types

type BlockRequestFunc

type BlockRequestFunc func(CallbackContext, uint64, []byte) (protocol.Message, error)

Callback function types

type BlockTxsRequestFunc

type BlockTxsRequestFunc func(CallbackContext, uint64, []byte, [8]byte) (protocol.Message, error)

Callback function 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) 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

func (c *Client) BlockRequest(slot uint64, hash []byte) (protocol.Message, error)

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) Start

func (c *Client) Start()

func (*Client) Stop

func (c *Client) Stop() error

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

type LeiosFetch struct {
	Client *Client
	Server *Server
}

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

type MsgBlockRangeRequest struct {
	protocol.MessageBase
	Start pcommon.Point
	End   pcommon.Point
}

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 Server

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

func NewServer

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

type VotesRequestFunc

type VotesRequestFunc func(CallbackContext, []MsgVotesRequestVoteId) (protocol.Message, error)

Callback function types

Jump to

Keyboard shortcuts

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