Documentation ¶
Index ¶
- Constants
- Variables
- func NewMsgFromCbor(msgType uint, data []byte) (protocol.Message, error)
- type BlockFetch
- type BlockFetchOptionFunc
- type BlockFunc
- 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 BlockFetch ¶
func New ¶
func New(protoOptions protocol.ProtocolOptions, cfg *Config) *BlockFetch
type BlockFetchOptionFunc ¶
type BlockFetchOptionFunc func(*Config)
func WithBatchStartTimeout ¶
func WithBatchStartTimeout(timeout time.Duration) BlockFetchOptionFunc
func WithBlockFunc ¶
func WithBlockFunc(blockFunc BlockFunc) BlockFetchOptionFunc
func WithBlockTimeout ¶
func WithBlockTimeout(timeout time.Duration) BlockFetchOptionFunc
func WithRequestRangeFunc ¶ added in v0.66.0
func WithRequestRangeFunc( requestRangeFunc RequestRangeFunc, ) BlockFetchOptionFunc
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 RequestRangeFunc RequestRangeFunc BatchStartTimeout time.Duration BlockTimeout time.Duration }
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
type WrappedBlock ¶
type WrappedBlock struct { cbor.StructAsArray Type uint RawBlock cbor.RawMessage }
Click to show internal directories.
Click to hide internal directories.