txsubmission

package
v0.89.0 Latest Latest
Warning

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

Go to latest
Published: Jun 21, 2024 License: Apache-2.0 Imports: 6 Imported by: 1

Documentation

Overview

Package txsubmission implements the Ouroboros TxSubmission protocol

Index

Constants

View Source
const (
	MessageTypeRequestTxIds = 0
	MessageTypeReplyTxIds   = 1
	MessageTypeRequestTxs   = 2
	MessageTypeReplyTxs     = 3
	MessageTypeDone         = 4
	MessageTypeInit         = 6
)

Message types

View Source
const (
	ProtocolName        = "tx-submission"
	ProtocolId   uint16 = 4
)

Protocol identifiers

Variables

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

TxSubmission protocol state machine

Functions

func NewMsgFromCbor

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

NewMsgFromCbor parses a TxSubmission message from CBOR

Types

type CallbackContext added in v0.78.0

type CallbackContext struct {
	ConnectionId connection.ConnectionId
	Client       *Client
	Server       *Server
}

Callback context

type Client

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

Client implements the TxSubmission client

func NewClient

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

NewClient returns a new TxSubmission client object

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
}

Config is used to configure the TxSubmission protocol instance

func NewConfig

func NewConfig(options ...TxSubmissionOptionFunc) Config

NewConfig returns a new TxSubmission config object with the provided options

type InitFunc

type InitFunc func(CallbackContext) 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

func (*MsgRequestTxs) MarshalCBOR added in v0.67.1

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

type RequestTxIdsFunc

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

Callback function types

type RequestTxsFunc

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

type Server

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

Server implements the TxSubmission server

func NewServer

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

NewServer returns a new TxSubmission server object

func (*Server) RequestTxIds added in v0.60.0

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

RequestTxIds requests the next set of TX identifiers from the remote node's mempool

func (*Server) RequestTxs added in v0.60.0

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

RequestTxs requests the content of the requested TX identifiers from the remote node's mempool

func (*Server) Start added in v0.73.3

func (s *Server) Start()

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
}

TxSubmission is a wrapper object that holds the client and server instances

func New

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

New returns a new TxSubmission object

type TxSubmissionOptionFunc

type TxSubmissionOptionFunc func(*Config)

TxSubmissionOptionFunc represents a function used to modify the TxSubmission protocol config

func WithIdleTimeout

func WithIdleTimeout(timeout time.Duration) TxSubmissionOptionFunc

WithIdleTimeout specifies the timeout for waiting for new transactions from the remote node's mempool

func WithInitFunc

func WithInitFunc(initFunc InitFunc) TxSubmissionOptionFunc

WithInitFunc specifies the Init callback function

func WithRequestTxIdsFunc

func WithRequestTxIdsFunc(
	requestTxIdsFunc RequestTxIdsFunc,
) TxSubmissionOptionFunc

WithRequestTxIdsFunc specifies the RequestTxIds callback function

func WithRequestTxsFunc

func WithRequestTxsFunc(requestTxsFunc RequestTxsFunc) TxSubmissionOptionFunc

WithRequestTxsFunc specifies the RequestTxs callback function

Jump to

Keyboard shortcuts

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