txsubmission

package
v0.13.2 Latest Latest
Warning

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

Go to latest
Published: May 5, 2022 License: Apache-2.0 Imports: 3 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_HELLO          = 6
)
View Source
const (
	PROTOCOL_NAME        = "tx-submission"
	PROTOCOL_ID   uint16 = 4
)

Variables

View Source
var (
	STATE_HELLO              = protocol.NewState(1, "Hello")
	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_HELLO: protocol.StateMapEntry{
		Agency: protocol.AGENCY_CLIENT,
		Transitions: []protocol.StateTransition{
			{
				MsgType:  MESSAGE_TYPE_HELLO,
				NewState: STATE_IDLE,
			},
		},
	},
	STATE_IDLE: protocol.StateMapEntry{
		Agency: protocol.AGENCY_SERVER,
		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.AGENCY_CLIENT,
		Transitions: []protocol.StateTransition{
			{
				MsgType:  MESSAGE_TYPE_REPLY_TX_IDS,
				NewState: STATE_IDLE,
			},
		},
	},
	STATE_TX_IDS_NONBLOCKING: protocol.StateMapEntry{
		Agency: protocol.AGENCY_CLIENT,
		Transitions: []protocol.StateTransition{
			{
				MsgType:  MESSAGE_TYPE_REPLY_TX_IDS,
				NewState: STATE_IDLE,
			},
		},
	},
	STATE_TXS: protocol.StateMapEntry{
		Agency: protocol.AGENCY_CLIENT,
		Transitions: []protocol.StateTransition{
			{
				MsgType:  MESSAGE_TYPE_REPLY_TXS,
				NewState: STATE_IDLE,
			},
		},
	},
	STATE_DONE: protocol.StateMapEntry{
		Agency: protocol.AGENCY_NONE,
	},
}

Functions

func NewMsgFromCbor

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

Types

type CallbackConfig

type CallbackConfig struct {
	RequestTxIdsFunc RequestTxIdsFunc
	ReplyTxIdsFunc   ReplyTxIdsFunc
	RequestTxsFunc   RequestTxsFunc
	ReplyTxsFunc     ReplyTxsFunc
	DoneFunc         DoneFunc
	HelloFunc        HelloFunc
}

type DoneFunc

type DoneFunc func() error

type HelloFunc

type HelloFunc func() error

type MsgDone

type MsgDone struct {
	protocol.MessageBase
}

func NewMsgDone

func NewMsgDone() *MsgDone

type MsgHello

type MsgHello struct {
	protocol.MessageBase
}

func NewMsgHello

func NewMsgHello() *MsgHello

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 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 {
	*protocol.Protocol
	// contains filtered or unexported fields
}

func New

func New(options protocol.ProtocolOptions, callbackConfig *CallbackConfig) *TxSubmission

Jump to

Keyboard shortcuts

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