txsubmission

package
v0.29.0 Latest Latest
Warning

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

Go to latest
Published: Feb 15, 2023 License: Apache-2.0 Imports: 4 Imported by: 0

Documentation

Index

Constants

View Source
const (
	MESSAGE_TYPE_REQUEST_TX_IDS = 0
	MESSAGE_TYPE_REPLY_TX_IDS   = 1
	MESSAGE_TYPE_REQUEST_TXS    = 2
	MESSAGE_TYPE_REPLY_TXS      = 3
	MESSAGE_TYPE_DONE           = 4
	MESSAGE_TYPE_INIT           = 6
)
View Source
const (
	PROTOCOL_NAME        = "tx-submission"
	PROTOCOL_ID   uint16 = 4
)

Variables

View Source
var (
	STATE_INIT               = protocol.NewState(1, "Init")
	STATE_IDLE               = protocol.NewState(2, "Idle")
	STATE_TX_IDS_BLOCKING    = protocol.NewState(3, "TxIdsBlocking")
	STATE_TX_IDS_NONBLOCKING = protocol.NewState(4, "TxIdsNonBlocking")
	STATE_TXS                = protocol.NewState(5, "Txs")
	STATE_DONE               = protocol.NewState(6, "Done")
)
View Source
var StateMap = protocol.StateMap{
	STATE_INIT: protocol.StateMapEntry{
		Agency: protocol.AgencyClient,
		Transitions: []protocol.StateTransition{
			{
				MsgType:  MESSAGE_TYPE_INIT,
				NewState: STATE_IDLE,
			},
		},
	},
	STATE_IDLE: protocol.StateMapEntry{
		Agency: protocol.AgencyServer,
		Transitions: []protocol.StateTransition{
			{
				MsgType:  MESSAGE_TYPE_REQUEST_TX_IDS,
				NewState: STATE_TX_IDS_BLOCKING,

				MatchFunc: func(msg protocol.Message) bool {
					msgRequestTxIds := msg.(*MsgRequestTxIds)
					return msgRequestTxIds.Blocking
				},
			},
			{
				MsgType:  MESSAGE_TYPE_REQUEST_TX_IDS,
				NewState: STATE_TX_IDS_NONBLOCKING,

				MatchFunc: func(msg protocol.Message) bool {
					msgRequestTxIds := msg.(*MsgRequestTxIds)
					return !msgRequestTxIds.Blocking
				},
			},
			{
				MsgType:  MESSAGE_TYPE_REQUEST_TXS,
				NewState: STATE_TXS,
			},
		},
	},
	STATE_TX_IDS_BLOCKING: protocol.StateMapEntry{
		Agency: protocol.AgencyClient,
		Transitions: []protocol.StateTransition{
			{
				MsgType:  MESSAGE_TYPE_REPLY_TX_IDS,
				NewState: STATE_IDLE,
			},
			{
				MsgType:  MESSAGE_TYPE_DONE,
				NewState: STATE_DONE,
			},
		},
	},
	STATE_TX_IDS_NONBLOCKING: protocol.StateMapEntry{
		Agency: protocol.AgencyClient,
		Transitions: []protocol.StateTransition{
			{
				MsgType:  MESSAGE_TYPE_REPLY_TX_IDS,
				NewState: STATE_IDLE,
			},
		},
	},
	STATE_TXS: protocol.StateMapEntry{
		Agency: protocol.AgencyClient,
		Transitions: []protocol.StateTransition{
			{
				MsgType:  MESSAGE_TYPE_REPLY_TXS,
				NewState: STATE_IDLE,
			},
		},
	},
	STATE_DONE: protocol.StateMapEntry{
		Agency: protocol.AgencyNone,
	},
}

Functions

func NewMsgFromCbor

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

Types

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

type Config added in v0.18.0

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

func NewConfig added in v0.25.0

func NewConfig(options ...TxSubmissionOptionFunc) Config

type DoneFunc

type DoneFunc func() error

type InitFunc added in v0.19.0

type InitFunc func() error

type MsgDone

type MsgDone struct {
	protocol.MessageBase
}

func NewMsgDone

func NewMsgDone() *MsgDone

type MsgInit added in v0.19.0

type MsgInit struct {
	protocol.MessageBase
}

func NewMsgInit added in v0.19.0

func NewMsgInit() *MsgInit

type MsgReplyTxIds

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

func NewMsgReplyTxIds

func NewMsgReplyTxIds(txIds []TxIdAndSize) *MsgReplyTxIds

type MsgReplyTxs

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

func NewMsgReplyTxs

func NewMsgReplyTxs(txs []TxBody) *MsgReplyTxs

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 ReplyTxIdsFunc

type ReplyTxIdsFunc func(interface{}) error

type ReplyTxsFunc

type ReplyTxsFunc func(interface{}) error

type RequestTxIdsFunc

type RequestTxIdsFunc func(bool, uint16, uint16) error

Callback function types

type RequestTxsFunc

type RequestTxsFunc func(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 TxBody added in v0.12.1

type TxBody struct {
	EraId  uint16
	TxBody []byte
}

type TxId added in v0.12.1

type TxId struct {
	EraId uint16
	TxId  [32]byte
}

type TxIdAndSize added in v0.12.1

type TxIdAndSize struct {
	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 added in v0.25.0

type TxSubmissionOptionFunc func(*Config)

func WithDoneFunc added in v0.25.0

func WithDoneFunc(doneFunc DoneFunc) TxSubmissionOptionFunc

func WithIdleTimeout added in v0.25.0

func WithIdleTimeout(timeout time.Duration) TxSubmissionOptionFunc

func WithInitFunc added in v0.25.0

func WithInitFunc(initFunc InitFunc) TxSubmissionOptionFunc

func WithReplyTxIdsFunc added in v0.25.0

func WithReplyTxIdsFunc(replyTxIdsFunc ReplyTxIdsFunc) TxSubmissionOptionFunc

func WithReplyTxsFunc added in v0.25.0

func WithReplyTxsFunc(replyTxsFunc ReplyTxsFunc) TxSubmissionOptionFunc

func WithRequestTxIdsFunc added in v0.25.0

func WithRequestTxIdsFunc(requestTxIdsFunc RequestTxIdsFunc) TxSubmissionOptionFunc

func WithRequestTxsFunc added in v0.25.0

func WithRequestTxsFunc(requestTxsFunc RequestTxsFunc) TxSubmissionOptionFunc

Jump to

Keyboard shortcuts

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