Documentation ¶
Overview ¶
Package txsubmission implements the Ouroboros TxSubmission protocol
Index ¶
- Constants
- Variables
- func NewMsgFromCbor(msgType uint, data []byte) (protocol.Message, error)
- type CallbackContext
- type Client
- type Config
- type InitFunc
- type MsgDone
- type MsgInit
- type MsgReplyTxIds
- type MsgReplyTxs
- type MsgRequestTxIds
- type MsgRequestTxs
- type RequestTxIdsFunc
- type RequestTxsFunc
- type Server
- type TxBody
- type TxId
- type TxIdAndSize
- type TxSubmission
- type TxSubmissionOptionFunc
Constants ¶
const ( MessageTypeRequestTxIds = 0 MessageTypeReplyTxIds = 1 MessageTypeRequestTxs = 2 MessageTypeReplyTxs = 3 MessageTypeDone = 4 MessageTypeInit = 6 )
Message types
const ( ProtocolName = "tx-submission" ProtocolId uint16 = 4 )
Protocol identifiers
Variables ¶
var StateMap = protocol.StateMap{ // contains filtered or unexported fields }
TxSubmission protocol state machine
Functions ¶
Types ¶
type CallbackContext ¶ added in v0.78.0
type CallbackContext struct { ConnectionId connection.ConnectionId Client *Client Server *Server }
Callback context
type Client ¶
Client implements the TxSubmission client
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 ¶
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
RequestTxs requests the content of the requested TX identifiers from the remote node's mempool
type TxBody ¶
type TxBody struct { cbor.StructAsArray EraId uint16 TxBody []byte }
func (*TxBody) MarshalCBOR ¶ added in v0.53.0
type TxIdAndSize ¶
type TxIdAndSize struct { cbor.StructAsArray TxId TxId Size uint32 }
type TxSubmission ¶
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