chainsync

package
v0.21.0 Latest Latest
Warning

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

Go to latest
Published: Nov 28, 2022 License: Apache-2.0 Imports: 7 Imported by: 0

Documentation

Index

Constants

View Source
const (
	PROTOCOL_NAME          = "chain-sync"
	PROTOCOL_ID_NTN uint16 = 2
	PROTOCOL_ID_NTC uint16 = 5
)
View Source
const (
	MESSAGE_TYPE_REQUEST_NEXT        = 0
	MESSAGE_TYPE_AWAIT_REPLY         = 1
	MESSAGE_TYPE_ROLL_FORWARD        = 2
	MESSAGE_TYPE_ROLL_BACKWARD       = 3
	MESSAGE_TYPE_FIND_INTERSECT      = 4
	MESSAGE_TYPE_INTERSECT_FOUND     = 5
	MESSAGE_TYPE_INTERSECT_NOT_FOUND = 6
	MESSAGE_TYPE_DONE                = 7
)

Variables

View Source
var (
	STATE_IDLE       = protocol.NewState(1, "Idle")
	STATE_CAN_AWAIT  = protocol.NewState(2, "CanAwait")
	STATE_MUST_REPLY = protocol.NewState(3, "MustReply")
	STATE_INTERSECT  = protocol.NewState(4, "Intersect")
	STATE_DONE       = protocol.NewState(5, "Done")
)

Functions

func NewMsgFromCbor added in v0.10.0

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

func NewMsgFromCborNtC added in v0.10.0

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

func NewMsgFromCborNtN added in v0.10.0

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

Types

type ChainSync

type ChainSync struct {
	Client *Client
	Server *Server
}

func New

func New(protoOptions protocol.ProtocolOptions, cfg *Config) *ChainSync

type Client added in v0.19.0

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

func NewClient added in v0.19.0

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

func (*Client) Stop added in v0.21.0

func (c *Client) Stop() error

func (*Client) Sync added in v0.21.0

func (c *Client) Sync(intersectPoints []common.Point) error

type Config added in v0.18.0

type Config struct {
	RollBackwardFunc RollBackwardFunc
	RollForwardFunc  RollForwardFunc
}

type IntersectNotFoundError added in v0.21.0

type IntersectNotFoundError struct {
}

func (IntersectNotFoundError) Error added in v0.21.0

func (e IntersectNotFoundError) Error() string

type MsgAwaitReply added in v0.10.0

type MsgAwaitReply struct {
	protocol.MessageBase
}

func NewMsgAwaitReply added in v0.12.1

func NewMsgAwaitReply() *MsgAwaitReply

type MsgDone added in v0.10.0

type MsgDone struct {
	protocol.MessageBase
}

func NewMsgDone added in v0.12.1

func NewMsgDone() *MsgDone

type MsgFindIntersect added in v0.10.0

type MsgFindIntersect struct {
	protocol.MessageBase
	Points []common.Point
}

func NewMsgFindIntersect added in v0.10.0

func NewMsgFindIntersect(points []common.Point) *MsgFindIntersect

type MsgIntersectFound added in v0.10.0

type MsgIntersectFound struct {
	protocol.MessageBase
	Point common.Point
	Tip   Tip
}

func NewMsgIntersectFound added in v0.12.1

func NewMsgIntersectFound(point common.Point, tip Tip) *MsgIntersectFound

type MsgIntersectNotFound added in v0.10.0

type MsgIntersectNotFound struct {
	protocol.MessageBase
	Tip Tip
}

func NewMsgIntersectNotFound added in v0.12.1

func NewMsgIntersectNotFound(tip Tip) *MsgIntersectNotFound

type MsgRequestNext added in v0.10.0

type MsgRequestNext struct {
	protocol.MessageBase
}

func NewMsgRequestNext added in v0.10.0

func NewMsgRequestNext() *MsgRequestNext

type MsgRollBackward added in v0.10.0

type MsgRollBackward struct {
	protocol.MessageBase
	Point common.Point
	Tip   Tip
}

func NewMsgRollBackward added in v0.12.1

func NewMsgRollBackward(point common.Point, tip Tip) *MsgRollBackward

type MsgRollForwardNtC added in v0.10.0

type MsgRollForwardNtC struct {
	protocol.MessageBase
	WrappedBlock cbor.Tag
	Tip          Tip
	// contains filtered or unexported fields
}

func NewMsgRollForwardNtC added in v0.12.1

func NewMsgRollForwardNtC(blockType uint, blockCbor []byte, tip Tip) *MsgRollForwardNtC

func (*MsgRollForwardNtC) BlockCbor added in v0.13.1

func (m *MsgRollForwardNtC) BlockCbor() []byte

func (*MsgRollForwardNtC) BlockType added in v0.13.1

func (m *MsgRollForwardNtC) BlockType() uint

type MsgRollForwardNtN added in v0.10.0

type MsgRollForwardNtN struct {
	protocol.MessageBase
	WrappedHeader WrappedHeader
	Tip           Tip
}

func NewMsgRollForwardNtN added in v0.12.1

func NewMsgRollForwardNtN(era uint, byronType uint, blockCbor []byte, tip Tip) *MsgRollForwardNtN

type RollBackwardFunc added in v0.18.0

type RollBackwardFunc func(common.Point, Tip) error

Callback function types

type RollForwardFunc added in v0.18.0

type RollForwardFunc func(uint, interface{}, Tip) error

type Server added in v0.19.0

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

func NewServer added in v0.19.0

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

type Tip added in v0.10.0

type Tip struct {
	Point       common.Point
	BlockNumber uint64
	// contains filtered or unexported fields
}

type WrappedBlock added in v0.10.0

type WrappedBlock struct {
	BlockType uint
	BlockCbor cbor.RawMessage
	// contains filtered or unexported fields
}

func NewWrappedBlock added in v0.13.1

func NewWrappedBlock(blockType uint, blockCbor []byte) *WrappedBlock

type WrappedHeader added in v0.10.0

type WrappedHeader struct {
	Era        uint
	RawMessage cbor.RawMessage
	// contains filtered or unexported fields
}

func NewWrappedHeader added in v0.13.1

func NewWrappedHeader(era uint, byronType uint, blockCbor []byte) *WrappedHeader

func (*WrappedHeader) ByronType added in v0.13.1

func (w *WrappedHeader) ByronType() uint

func (*WrappedHeader) HeaderCbor added in v0.13.1

func (w *WrappedHeader) HeaderCbor() []byte

func (*WrappedHeader) MarshalCBOR added in v0.13.1

func (w *WrappedHeader) MarshalCBOR() ([]byte, error)

func (*WrappedHeader) UnmarshalCBOR added in v0.13.1

func (w *WrappedHeader) UnmarshalCBOR(data []byte) error

Jump to

Keyboard shortcuts

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