txsubmission

package
v0.67.0 Latest Latest
Warning

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

Go to latest
Published: Dec 4, 2023 License: Apache-2.0 Imports: 5 Imported by: 1

Documentation

Index

Constants

View Source
const (
	MessageTypeRequestTxIds = 0
	MessageTypeReplyTxIds   = 1
	MessageTypeRequestTxs   = 2
	MessageTypeReplyTxs     = 3
	MessageTypeDone         = 4
	MessageTypeInit         = 6
)
View Source
const (
	ProtocolName        = "tx-submission"
	ProtocolId   uint16 = 4
)

Variables

View Source
var StateMap = protocol.StateMap{
	// contains filtered or unexported fields
}

Functions

func NewMsgFromCbor

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

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) Init added in v0.49.0

func (c *Client) Init()

Init tells the server to begin asking us for transactions

type Config

type Config struct {
	RequestTxIdsFunc RequestTxIdsFunc
	RequestTxsFunc   RequestTxsFunc
	InitFunc         InitFunc
	IdleTimeout      time.Duration
}

func NewConfig

func NewConfig(options ...TxSubmissionOptionFunc) Config

type InitFunc

type InitFunc func() error

type MsgDone

type MsgDone struct {
	protocol.MessageBase
}

func NewMsgDone

func NewMsgDone() *MsgDone

type MsgInit

type MsgInit struct {
	protocol.MessageBase
}

func NewMsgInit

func NewMsgInit() *MsgInit

type MsgReplyTxIds

type MsgReplyTxIds struct {
	protocol.MessageBase
	TxIds []TxIdAndSize
}

func NewMsgReplyTxIds

func NewMsgReplyTxIds(txIds []TxIdAndSize) *MsgReplyTxIds

func (*MsgReplyTxIds) MarshalCBOR added in v0.53.0

func (m *MsgReplyTxIds) MarshalCBOR() ([]byte, error)

type MsgReplyTxs

type MsgReplyTxs struct {
	protocol.MessageBase
	Txs []TxBody
}

func NewMsgReplyTxs

func NewMsgReplyTxs(txs []TxBody) *MsgReplyTxs

func (*MsgReplyTxs) MarshalCBOR added in v0.53.0

func (m *MsgReplyTxs) MarshalCBOR() ([]byte, error)

type MsgRequestTxIds

type MsgRequestTxIds struct {
	protocol.MessageBase
	Blocking bool
	Ack      uint16
	Req      uint16
}

func NewMsgRequestTxIds

func NewMsgRequestTxIds(
	blocking bool,
	ack uint16,
	req uint16,
) *MsgRequestTxIds

type MsgRequestTxs

type MsgRequestTxs struct {
	protocol.MessageBase
	TxIds []TxId
}

func NewMsgRequestTxs

func NewMsgRequestTxs(txIds []TxId) *MsgRequestTxs

type RequestTxIdsFunc

type RequestTxIdsFunc func(bool, uint16, uint16) ([]TxIdAndSize, error)

Callback function types

type RequestTxsFunc

type RequestTxsFunc func([]TxId) ([]TxBody, error)

type Server

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

func NewServer

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

func (*Server) RequestTxIds added in v0.60.0

func (s *Server) RequestTxIds(
	blocking bool,
	reqCount int,
) ([]TxIdAndSize, error)

func (*Server) RequestTxs added in v0.60.0

func (s *Server) RequestTxs(txIds []TxId) ([]TxBody, error)

type TxBody

type TxBody struct {
	cbor.StructAsArray
	EraId  uint16
	TxBody []byte
}

func (*TxBody) MarshalCBOR added in v0.53.0

func (t *TxBody) MarshalCBOR() ([]byte, error)

type TxId

type TxId struct {
	cbor.StructAsArray
	EraId uint16
	TxId  [32]byte
}

type TxIdAndSize

type TxIdAndSize struct {
	cbor.StructAsArray
	TxId TxId
	Size uint32
}

type TxSubmission

type TxSubmission struct {
	Client *Client
	Server *Server
}

func New

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

type TxSubmissionOptionFunc

type TxSubmissionOptionFunc func(*Config)

func WithIdleTimeout

func WithIdleTimeout(timeout time.Duration) TxSubmissionOptionFunc

func WithInitFunc

func WithInitFunc(initFunc InitFunc) TxSubmissionOptionFunc

func WithRequestTxIdsFunc

func WithRequestTxIdsFunc(
	requestTxIdsFunc RequestTxIdsFunc,
) TxSubmissionOptionFunc

func WithRequestTxsFunc

func WithRequestTxsFunc(requestTxsFunc RequestTxsFunc) TxSubmissionOptionFunc

Jump to

Keyboard shortcuts

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