Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type EpochQueue

type EpochQueue struct {
	// contains filtered or unexported fields
}

    EpochQueue represents a client epoch queue.

    func NewEpochQueue

    func NewEpochQueue() *EpochQueue

      NewEpochQueue creates a client epoch queue.

      func (*EpochQueue) Enqueue

      func (eq *EpochQueue) Enqueue(note *msgjson.EpochOrderNote) error

        Enqueue appends the provided order note to the epoch queue.

        func (*EpochQueue) Exists

        func (eq *EpochQueue) Exists(oid order.OrderID) bool

          Exists checks if the provided order id is in the queue.

          func (*EpochQueue) GenerateMatchProof

          func (eq *EpochQueue) GenerateMatchProof(preimages []order.Preimage, misses []order.OrderID) (msgjson.Bytes, msgjson.Bytes, error)

            GenerateMatchProof calculates the sorting seed used in order matching as well as the commitment checksum from the provided epoch queue preimages and misses.

            The epoch queue needs to be reset if there are preimage mismatches or non-existent orders for preimage errors.

            func (*EpochQueue) Orders

            func (eq *EpochQueue) Orders() (orders []*Order)

              Orders returns the epoch queue as a []*Order.

              func (*EpochQueue) Size

              func (eq *EpochQueue) Size() int

                Size returns the number of entries in the epoch queue.

                type Order

                type Order struct {
                	OrderID  order.OrderID
                	Side     uint8
                	Quantity uint64
                	Rate     uint64
                	Time     uint64
                	// Epoch is only used in the epoch queue, otherwise it is ignored.
                	Epoch uint64
                }

                  Order represents an ask or bid.

                  type OrderBook

                  type OrderBook struct {
                  	// contains filtered or unexported fields
                  }

                    OrderBook represents a client tracked order book.

                    func NewOrderBook

                    func NewOrderBook(logger dex.Logger) *OrderBook

                      NewOrderBook creates a new order book.

                      func (*OrderBook) BestNOrders

                      func (ob *OrderBook) BestNOrders(n int, side uint8) ([]*Order, bool, error)

                        BestNOrders returns the best n orders from the provided side.

                        func (*OrderBook) Book

                        func (ob *OrderBook) Book(note *msgjson.BookOrderNote) error

                          Book adds a new order to the order book.

                          func (*OrderBook) Enqueue

                          func (ob *OrderBook) Enqueue(note *msgjson.EpochOrderNote) error

                            Enqueue appends the provided order note to the corresponding epoch's queue.

                            func (*OrderBook) MidGap

                            func (ob *OrderBook) MidGap() (uint64, error)

                              MidGap returns the mid-gap price for the market. If one market side is empty the bets rate from the other side will be used. If both sides are empty, an error will be returned.

                              func (*OrderBook) Orders

                              func (ob *OrderBook) Orders() ([]*Order, []*Order, []*Order)

                                Orders is the full order book, as slices of sorted buys and sells, and unsorted epoch orders in the current epoch.

                                func (*OrderBook) Reset

                                func (ob *OrderBook) Reset(snapshot *msgjson.OrderBook) error

                                  Reset forcibly updates a client tracked order book with an order book snapshot. This resets the sequence. TODO: eliminate this and half of the mutexes!

                                  func (*OrderBook) Sync

                                  func (ob *OrderBook) Sync(snapshot *msgjson.OrderBook) error

                                    Sync updates a client tracked order book with an order book snapshot. It is an error if the the OrderBook is already synced.

                                    func (*OrderBook) Unbook

                                    func (ob *OrderBook) Unbook(note *msgjson.UnbookOrderNote) error

                                      Unbook removes an order from the order book.

                                      func (*OrderBook) UpdateRemaining

                                      func (ob *OrderBook) UpdateRemaining(note *msgjson.UpdateRemainingNote) error

                                        UpdateRemaining updates the remaining quantity of a booked order.

                                        func (*OrderBook) ValidateMatchProof

                                        func (ob *OrderBook) ValidateMatchProof(note msgjson.MatchProofNote) error

                                          ValidateMatchProof ensures the match proof data provided is correct by comparing it to a locally generated proof from the same epoch queue.

                                          type RemoteOrderBook

                                          type RemoteOrderBook interface {
                                          	// Sync instantiates a client tracked order book with the
                                          	// current order book snapshot.
                                          	Sync(*msgjson.OrderBook)
                                          	// Book adds a new order to the order book.
                                          	Book(*msgjson.BookOrderNote)
                                          	// Unbook removes an order from the order book.
                                          	Unbook(*msgjson.UnbookOrderNote) error
                                          }

                                            RemoteOrderBook defines the functions a client tracked order book must implement.