Documentation ¶
Index ¶
- Constants
- Variables
- func NewMsgFromCbor(msgType uint, data []byte) (protocol.Message, error)
- type BlockFetch
- type BlockFetchOptionFunc
- type BlockFunc
- type Client
- type Config
- type MsgBatchDone
- type MsgBlock
- type MsgClientDone
- type MsgNoBlocks
- type MsgRequestRange
- type MsgStartBatch
- type Server
- type WrappedBlock
Constants ¶
View Source
const ( PROTOCOL_NAME = "block-fetch" PROTOCOL_ID uint16 = 3 )
View Source
const ( MESSAGE_TYPE_REQUEST_RANGE = 0 MESSAGE_TYPE_CLIENT_DONE = 1 MESSAGE_TYPE_START_BATCH = 2 MESSAGE_TYPE_NO_BLOCKS = 3 MESSAGE_TYPE_BLOCK = 4 MESSAGE_TYPE_BATCH_DONE = 5 )
Variables ¶
View Source
var ( STATE_IDLE = protocol.NewState(1, "Idle") STATE_BUSY = protocol.NewState(2, "Busy") STATE_STREAMING = protocol.NewState(3, "Streaming") STATE_DONE = protocol.NewState(4, "Done") )
View Source
var StateMap = protocol.StateMap{ STATE_IDLE: protocol.StateMapEntry{ Agency: protocol.AgencyClient, Transitions: []protocol.StateTransition{ { MsgType: MESSAGE_TYPE_REQUEST_RANGE, NewState: STATE_BUSY, }, { MsgType: MESSAGE_TYPE_CLIENT_DONE, NewState: STATE_DONE, }, }, }, STATE_BUSY: protocol.StateMapEntry{ Agency: protocol.AgencyServer, Transitions: []protocol.StateTransition{ { MsgType: MESSAGE_TYPE_START_BATCH, NewState: STATE_STREAMING, }, { MsgType: MESSAGE_TYPE_NO_BLOCKS, NewState: STATE_IDLE, }, }, }, STATE_STREAMING: protocol.StateMapEntry{ Agency: protocol.AgencyServer, Transitions: []protocol.StateTransition{ { MsgType: MESSAGE_TYPE_BLOCK, NewState: STATE_STREAMING, }, { MsgType: MESSAGE_TYPE_BATCH_DONE, NewState: STATE_IDLE, }, }, }, STATE_DONE: 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
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 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 ¶
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 ¶
type MsgRequestRange struct { protocol.MessageBase Start interface{} //point End interface{} //point }
func NewMsgRequestRange ¶
func NewMsgRequestRange(start interface{}, end interface{}) *MsgRequestRange
type MsgStartBatch ¶
type MsgStartBatch struct {
protocol.MessageBase
}
func NewMsgStartBatch ¶
func NewMsgStartBatch() *MsgStartBatch
type WrappedBlock ¶
type WrappedBlock struct { Type uint RawBlock cbor.RawMessage // contains filtered or unexported fields }
Click to show internal directories.
Click to hide internal directories.