localtxmonitor

package
v0.103.4 Latest Latest
Warning

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

Go to latest
Published: Nov 10, 2024 License: Apache-2.0 Imports: 8 Imported by: 1

Documentation

Overview

Package localtxmonitor implements the Ouroboros local-tx-monitor protocol

Index

Constants

View Source
const (
	ProtocolName        = "local-tx-monitor"
	ProtocolId   uint16 = 9
)

Protocol identifiers

View Source
const (
	MessageTypeDone          = 0
	MessageTypeAcquire       = 1
	MessageTypeAcquired      = 2
	MessageTypeRelease       = 3
	MessageTypeNextTx        = 5
	MessageTypeReplyNextTx   = 6
	MessageTypeHasTx         = 7
	MessageTypeReplyHasTx    = 8
	MessageTypeGetSizes      = 9
	MessageTypeReplyGetSizes = 10
)

Message types

Variables

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

LocalTxMonitor protocol state machine

Functions

func NewMsgFromCbor

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

NewMsgFromCbor parses a LocalTxMonitor 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 LocalTxMonitor client

func NewClient

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

NewClient returns a new LocalTxMonitor client object

func (*Client) Acquire

func (c *Client) Acquire() error

Acquire starts the acquire process for a current mempool snapshot

func (*Client) GetSizes

func (c *Client) GetSizes() (uint32, uint32, uint32, error)

GetSizes returns the capacity (in bytes), size (in bytes), and number of transactions in the mempool snapshot

func (*Client) HasTx

func (c *Client) HasTx(txId []byte) (bool, error)

HasTx returns whether or not the specified transaction ID exists in the mempool snapshot

func (*Client) NextTx

func (c *Client) NextTx() ([]byte, error)

NextTx returns the next transaction in the mempool snapshot

func (*Client) Release

func (c *Client) Release() error

Release releases the previously acquired mempool snapshot

func (*Client) Start added in v0.73.3

func (c *Client) Start()

func (*Client) Stop

func (c *Client) Stop() error

Stop transitions the protocol to the Done state. No more operations will be possible

type Config

type Config struct {
	GetMempoolFunc GetMempoolFunc
	AcquireTimeout time.Duration
	QueryTimeout   time.Duration
}

Config is used to configure the LocalTxMonitor protocol instance

func NewConfig

func NewConfig(options ...LocalTxMonitorOptionFunc) Config

NewConfig returns a new LocalTxMonitor config object with the provided options

type GetMempoolFunc added in v0.60.0

type GetMempoolFunc func(CallbackContext) (uint64, uint32, []TxAndEraId, error)

Callback function types

type LocalTxMonitor

type LocalTxMonitor struct {
	Client *Client
	Server *Server
}

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

func New

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

New returns a new LocalTxMonitor object

type LocalTxMonitorOptionFunc

type LocalTxMonitorOptionFunc func(*Config)

LocalTxMonitorOptionFunc represents a function used to modify the LocalTxMonitor protocol config

func WithAcquireTimeout

func WithAcquireTimeout(timeout time.Duration) LocalTxMonitorOptionFunc

WithAcquireTimeout specifies the timeout for acquire operations when acting as a client

func WithGetMempoolFunc added in v0.60.0

func WithGetMempoolFunc(
	getMempoolFunc GetMempoolFunc,
) LocalTxMonitorOptionFunc

WithGetMempoolFunc specifies the callback function for retrieving the mempool

func WithQueryTimeout

func WithQueryTimeout(timeout time.Duration) LocalTxMonitorOptionFunc

WithQueryTimeout specifies the timeout for query operations when acting as a client

type MsgAcquire

type MsgAcquire struct {
	protocol.MessageBase
}

func NewMsgAcquire

func NewMsgAcquire() *MsgAcquire

type MsgAcquired

type MsgAcquired struct {
	protocol.MessageBase
	SlotNo uint64
}

func NewMsgAcquired

func NewMsgAcquired(slotNo uint64) *MsgAcquired

type MsgDone

type MsgDone struct {
	protocol.MessageBase
}

func NewMsgDone

func NewMsgDone() *MsgDone

type MsgGetSizes

type MsgGetSizes struct {
	protocol.MessageBase
}

func NewMsgGetSizes

func NewMsgGetSizes() *MsgGetSizes

type MsgHasTx

type MsgHasTx struct {
	protocol.MessageBase
	TxId []byte
}

func NewMsgHasTx

func NewMsgHasTx(txId []byte) *MsgHasTx

type MsgNextTx

type MsgNextTx struct {
	protocol.MessageBase
}

func NewMsgNextTx

func NewMsgNextTx() *MsgNextTx

type MsgRelease

type MsgRelease struct {
	protocol.MessageBase
}

func NewMsgRelease

func NewMsgRelease() *MsgRelease

type MsgReplyGetSizes

type MsgReplyGetSizes struct {
	protocol.MessageBase
	Result MsgReplyGetSizesResult
}

func NewMsgReplyGetSizes

func NewMsgReplyGetSizes(
	capacity uint32,
	size uint32,
	numberOfTxs uint32,
) *MsgReplyGetSizes

type MsgReplyGetSizesResult

type MsgReplyGetSizesResult struct {
	Capacity    uint32
	Size        uint32
	NumberOfTxs uint32
	// contains filtered or unexported fields
}

type MsgReplyHasTx

type MsgReplyHasTx struct {
	protocol.MessageBase
	Result bool
}

func NewMsgReplyHasTx

func NewMsgReplyHasTx(result bool) *MsgReplyHasTx

type MsgReplyNextTx

type MsgReplyNextTx struct {
	protocol.MessageBase
	Transaction MsgReplyNextTxTransaction
}

func NewMsgReplyNextTx

func NewMsgReplyNextTx(eraId uint8, tx []byte) *MsgReplyNextTx

func (*MsgReplyNextTx) MarshalCBOR

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

func (*MsgReplyNextTx) UnmarshalCBOR

func (m *MsgReplyNextTx) UnmarshalCBOR(data []byte) error

type MsgReplyNextTxTransaction

type MsgReplyNextTxTransaction struct {
	EraId uint8
	Tx    []byte
	// contains filtered or unexported fields
}

type Server

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

Server implements the LocalTxMonitor server

func NewServer

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

NewServer returns a new Server object

type TxAndEraId added in v0.60.0

type TxAndEraId struct {
	EraId uint
	Tx    []byte
	// contains filtered or unexported fields
}

Helper types

Jump to

Keyboard shortcuts

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