Documentation ¶
Index ¶
- type Operator
- func (op *Operator) GetShortestQueue() (*TxQueue, int, error)
- func (op *Operator) HandleError(m *types.Matches)
- func (op *Operator) HandleEvents() error
- func (op *Operator) HandleTrades(msg *types.OperatorMessage) error
- func (op *Operator) HandleTxError(m *types.Matches, errType string)
- func (op *Operator) PurgeQueues() error
- func (op *Operator) QueueTrade(m *types.Matches) error
- type OperatorInterface
- type TxQueue
- func (txq *TxQueue) ExecuteTrade(m *types.Matches, tag uint64) error
- func (txq *TxQueue) GetChannel() *amqp.Channel
- func (txq *TxQueue) HandleTxSuccess(m *types.Matches) error
- func (txq *TxQueue) Length() int
- func (txq *TxQueue) PublishPendingTrades(m *types.Matches) error
- func (txq *TxQueue) PurgePendingTrades() error
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Operator ¶
type Operator struct { AccountService interfaces.AccountService TradeService interfaces.TradeService OrderService interfaces.OrderService ObyteProvider interfaces.ObyteProvider TxQueues []*TxQueue QueueAddressIndex map[string]*TxQueue Broker *rabbitmq.Connection // contains filtered or unexported fields }
Operator manages the transaction queue that will eventually be sent to the exchange AA. The Operator Wallet must be equal to the matcher of submitted orders
func NewOperator ¶
func NewOperator( tradeService interfaces.TradeService, orderService interfaces.OrderService, accountService interfaces.AccountService, provider interfaces.ObyteProvider, conn *rabbitmq.Connection, ) (*Operator, error)
NewOperator creates a new operator struct. The error and trade events are received in the ErrorChannel and TradeChannel. Upon receiving errors and trades in their respective channels, event payloads are sent to the associated order maker and taker sockets through the through the event channel on the Order and Trade struct. In addition, an error event cancels the trade in the trading engine and makes the order available again.
func (*Operator) GetShortestQueue ¶
GetShortestQueue
func (*Operator) HandleError ¶
func (*Operator) HandleEvents ¶
Bug: In certain cases, the trade channel seems to be receiving additional unexpected trades. In the case TestSocketExecuteOrder (in file socket_test.go) is run on its own, everything is working correctly. However, in the case TestSocketExecuteOrder is run among other tests, some tradeLogs do not correspond to an order hash in the ordertrade mapping. I suspect this is because the event listener catches events from previous tests. It might be helpful to see how to listen to events from up to a certain block.
func (*Operator) HandleTrades ¶
func (op *Operator) HandleTrades(msg *types.OperatorMessage) error
func (*Operator) HandleTxError ¶
func (*Operator) PurgeQueues ¶
type OperatorInterface ¶
type TxQueue ¶
type TxQueue struct { Name string TradeService interfaces.TradeService OrderService interfaces.OrderService ObyteProvider interfaces.ObyteProvider Broker *rabbitmq.Connection }
func NewTxQueue ¶
func NewTxQueue( n string, tr interfaces.TradeService, p interfaces.ObyteProvider, o interfaces.OrderService, rabbitConn *rabbitmq.Connection, ) (*TxQueue, error)
NewTxQueue
func (*TxQueue) ExecuteTrade ¶
ExecuteTrade send a trade execution order to the AA. After sending the trade message, the trade is updated on the database and is published to the operator subscribers (order service)