chainsync

package
v0.19.0 Latest Latest
Warning

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

Go to latest
Published: Oct 29, 2022 License: Apache-2.0 Imports: 5 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 AwaitReplyFunc added in v0.18.0

type AwaitReplyFunc func() error

Callback function 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) FindIntersect added in v0.19.0

func (c *Client) FindIntersect(points []Point) error

func (*Client) RequestNext added in v0.19.0

func (c *Client) RequestNext() error

type Config added in v0.18.0

type Config struct {
	AwaitReplyFunc        AwaitReplyFunc
	RollBackwardFunc      RollBackwardFunc
	RollForwardFunc       RollForwardFunc
	IntersectFoundFunc    IntersectFoundFunc
	IntersectNotFoundFunc IntersectNotFoundFunc
	DoneFunc              DoneFunc
}

type DoneFunc added in v0.18.0

type DoneFunc func() error

type IntersectFoundFunc added in v0.18.0

type IntersectFoundFunc func(interface{}, interface{}) error

type IntersectNotFoundFunc added in v0.18.0

type IntersectNotFoundFunc func(interface{}) error

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 []Point
}

func NewMsgFindIntersect added in v0.10.0

func NewMsgFindIntersect(points []Point) *MsgFindIntersect

type MsgIntersectFound added in v0.10.0

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

func NewMsgIntersectFound added in v0.12.1

func NewMsgIntersectFound(point 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 Point
	Tip   Tip
}

func NewMsgRollBackward added in v0.12.1

func NewMsgRollBackward(point 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 Point added in v0.10.0

type Point struct {
	Slot uint64
	Hash []byte
	// contains filtered or unexported fields
}

func (*Point) MarshalCBOR added in v0.13.1

func (p *Point) MarshalCBOR() ([]byte, error)

func (*Point) UnmarshalCBOR added in v0.10.0

func (p *Point) UnmarshalCBOR(data []byte) error

A "point" can sometimes be empty, but the CBOR library gets grumpy about this when doing automatic decoding from an array, so we have to handle this case specially

type RollBackwardFunc added in v0.18.0

type RollBackwardFunc func(interface{}, interface{}) error

type RollForwardFunc added in v0.18.0

type RollForwardFunc func(uint, interface{}) 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       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