Documentation
¶
Index ¶
- Constants
- Variables
- func NewMsgFromCbor(msgType uint, data []byte) (protocol.Message, error)
- type BatchDoneFunc
- type BlockFetch
- type BlockFetchOptionFunc
- func WithBatchDoneFunc(batchDoneFunc BatchDoneFunc) BlockFetchOptionFunc
- func WithBatchStartTimeout(timeout time.Duration) BlockFetchOptionFunc
- func WithBlockFunc(blockFunc BlockFunc) BlockFetchOptionFunc
- func WithBlockRawFunc(blockRawFunc BlockRawFunc) BlockFetchOptionFunc
- func WithBlockTimeout(timeout time.Duration) BlockFetchOptionFunc
- func WithRecvQueueSize(size int) BlockFetchOptionFunc
- func WithRequestRangeFunc(requestRangeFunc RequestRangeFunc) BlockFetchOptionFunc
- type BlockFunc
- type BlockRawFunc
- type CallbackContext
- type Client
- type Config
- type MsgBatchDone
- type MsgBlock
- type MsgClientDone
- type MsgNoBlocks
- type MsgRequestRange
- type MsgStartBatch
- type RequestRangeFunc
- type Server
- type WrappedBlock
Constants ¶
View Source
const ( ProtocolName = "block-fetch" ProtocolId uint16 = 3 )
View Source
const ( MessageTypeRequestRange = 0 MessageTypeClientDone = 1 MessageTypeStartBatch = 2 MessageTypeNoBlocks = 3 MessageTypeBlock = 4 MessageTypeBatchDone = 5 )
Variables ¶
View Source
var ( StateIdle = protocol.NewState(1, "Idle") StateBusy = protocol.NewState(2, "Busy") StateStreaming = protocol.NewState(3, "Streaming") StateDone = protocol.NewState(4, "Done") )
View Source
var StateMap = protocol.StateMap{ StateIdle: protocol.StateMapEntry{ Agency: protocol.AgencyClient, Transitions: []protocol.StateTransition{ { MsgType: MessageTypeRequestRange, NewState: StateBusy, }, { MsgType: MessageTypeClientDone, NewState: StateDone, }, }, }, StateBusy: protocol.StateMapEntry{ Agency: protocol.AgencyServer, Transitions: []protocol.StateTransition{ { MsgType: MessageTypeStartBatch, NewState: StateStreaming, }, { MsgType: MessageTypeNoBlocks, NewState: StateIdle, }, }, }, StateStreaming: protocol.StateMapEntry{ Agency: protocol.AgencyServer, Transitions: []protocol.StateTransition{ { MsgType: MessageTypeBlock, NewState: StateStreaming, }, { MsgType: MessageTypeBatchDone, NewState: StateIdle, }, }, }, StateDone: protocol.StateMapEntry{ Agency: protocol.AgencyNone, }, }
Functions ¶
Types ¶
type BatchDoneFunc ¶ added in v0.104.0
type BatchDoneFunc func(CallbackContext) error
Callback function types
type BlockFetch ¶
func New ¶
func New(protoOptions protocol.ProtocolOptions, cfg *Config) *BlockFetch
type BlockFetchOptionFunc ¶
type BlockFetchOptionFunc func(*Config)
func WithBatchDoneFunc ¶ added in v0.104.0
func WithBatchDoneFunc(batchDoneFunc BatchDoneFunc) BlockFetchOptionFunc
func WithBatchStartTimeout ¶
func WithBatchStartTimeout(timeout time.Duration) BlockFetchOptionFunc
func WithBlockFunc ¶
func WithBlockFunc(blockFunc BlockFunc) BlockFetchOptionFunc
func WithBlockRawFunc ¶ added in v0.108.0
func WithBlockRawFunc(blockRawFunc BlockRawFunc) BlockFetchOptionFunc
func WithBlockTimeout ¶
func WithBlockTimeout(timeout time.Duration) BlockFetchOptionFunc
func WithRecvQueueSize ¶ added in v0.114.0
func WithRecvQueueSize(size int) BlockFetchOptionFunc
WithRecvQueueSize specifies the size of the received messages queue. This is useful to adjust the number of blocks that can be fetched at once when acting as a client
func WithRequestRangeFunc ¶ added in v0.66.0
func WithRequestRangeFunc( requestRangeFunc RequestRangeFunc, ) BlockFetchOptionFunc
type BlockFunc ¶
type BlockFunc func(CallbackContext, uint, ledger.Block) error
Callback function types
type BlockRawFunc ¶ added in v0.108.0
type BlockRawFunc func(CallbackContext, uint, []byte) error
Callback function types
type CallbackContext ¶ added in v0.78.0
type CallbackContext struct { ConnectionId connection.ConnectionId Client *Client Server *Server }
Callback context
type Client ¶
func (*Client) GetBlock ¶
GetBlock requests and returns a single block specified by the provided point
func (*Client) GetBlockRange ¶
GetBlockRange starts an async process to fetch all blocks in the specified range (inclusive)
type Config ¶
type Config struct { BlockFunc BlockFunc BlockRawFunc BlockRawFunc BatchDoneFunc BatchDoneFunc RequestRangeFunc RequestRangeFunc BatchStartTimeout time.Duration BlockTimeout time.Duration RecvQueueSize int }
func NewConfig ¶
func NewConfig(options ...BlockFetchOptionFunc) Config
type MsgBatchDone ¶
type MsgBatchDone struct {
protocol.MessageBase
}
func NewMsgBatchDone ¶
func NewMsgBatchDone() *MsgBatchDone
type MsgBlock ¶
type MsgBlock struct { protocol.MessageBase WrappedBlock []byte }
func NewMsgBlock ¶
func (MsgBlock) MarshalCBOR ¶ added in v0.66.0
type MsgClientDone ¶
type MsgClientDone struct {
protocol.MessageBase
}
func NewMsgClientDone ¶
func NewMsgClientDone() *MsgClientDone
type MsgNoBlocks ¶
type MsgNoBlocks struct {
protocol.MessageBase
}
func NewMsgNoBlocks ¶
func NewMsgNoBlocks() *MsgNoBlocks
type MsgRequestRange ¶
func NewMsgRequestRange ¶
func NewMsgRequestRange(start common.Point, end common.Point) *MsgRequestRange
type MsgStartBatch ¶
type MsgStartBatch struct {
protocol.MessageBase
}
func NewMsgStartBatch ¶
func NewMsgStartBatch() *MsgStartBatch
type RequestRangeFunc ¶ added in v0.66.0
Callback function types
type WrappedBlock ¶
type WrappedBlock struct { cbor.StructAsArray Type uint RawBlock cbor.RawMessage }
Click to show internal directories.
Click to hide internal directories.