blockfetch

package
v0.33.3 Latest Latest
Warning

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

Go to latest
Published: Apr 5, 2023 License: Apache-2.0 Imports: 7 Imported by: 2

Documentation

Index

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

Functions

func NewMsgFromCbor

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

Types

type BlockFetch

type BlockFetch struct {
	Client *Client
	Server *Server
}

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 BlockFunc

type BlockFunc func(ledger.Block) error

Callback function types

type Client

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

func NewClient

func NewClient(protoOptions protocol.ProtocolOptions, cfg *Config) *Client

func (*Client) GetBlock

func (c *Client) GetBlock(point common.Point) (ledger.Block, error)

GetBlock requests and returns a single block specified by the provided point

func (*Client) GetBlockRange

func (c *Client) GetBlockRange(start common.Point, end common.Point) error

GetBlockRange starts an async process to fetch all blocks in the specified range (inclusive)

func (*Client) Stop

func (c *Client) Stop() error

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

func NewMsgBlock(wrappedBlock []byte) *MsgBlock

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 Server

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

func NewServer

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

type WrappedBlock

type WrappedBlock struct {
	Type     uint
	RawBlock cbor.RawMessage
	// contains filtered or unexported fields
}

Jump to

Keyboard shortcuts

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