cxdb

package
v0.0.0-...-7ad0b1f Latest Latest
Warning

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

Go to latest
Published: Jun 19, 2022 License: MIT Imports: 2 Imported by: 0

README

cxdb

Build Status License GoDoc

The code which manages exchange datastore interactions is split into a set of useful interfaces:

SettlementEngine

SettlementEngine has two methods. One method checks whether or not a settlement execution could take place if it were executed (think of this as "can we credit this user X of an asset"). The second method actually executes the settlement execution(s).

AuctionEngine

AuctionEngine is the matching engine for auction orders. It has a place method, a cancel method, and a match method. The match method takes an auction ID as input, since orders cannot be matched cross-auction. This matches according to a clearing price based auction matching algorithm.

LimitEngine

LimitEngine is the matching engine for limit orders. It has a place method, a cancel method, and a match method. This matches according to a price-time priority auction matching algorithm.

AuctionOrderbook

AuctionOrderbook gets updated by the auction matching engine, and is viewable by the user. This also has other methods that may be useful, for example methods to get orders by ID, pubkey, or auction.

LimitOrderbook

LimitOrderbook is very similar to AuctionOrderbook except it does not have methods dependent on a specific auction, since limit orderbooks do not have auctions.

PuzzleStore

PuzzleStore is a simple store for storing timelock puzzles, as well as marking specific timelock puzzles to commit to or match.

DepositStore

DepositStore stores the mapping from pubkey to deposit address. This also keeps track of pending deposits. Pending deposits do not have a fixed number of confirmations, and can be set arbitrarily.

DB interface implementation status
  • SettlementEngine
    • cxdbsql
    • cxdbmemory
    • cxdbredis
  • AuctionEngine
    • cxdbsql
    • cxdbemory (partial)
    • cxdbredis
  • LimitEngine
    • cxdbsql
    • cxdbmemory
    • cxdbredis
  • AuctionOrderbook
    • cxdbsql
    • cxdbmemory
    • cxdbredis
  • LimitOrderbook
    • cxdbsql
    • cxdbmemory
    • cxdbredis
  • PuzzleStore
    • cxdbsql
    • cxdbmemory
    • cxdbredis
  • DepositStore
    • cxdbsql
    • cxdbmemory
    • cxdbredis

Some old code still exists in cxdbmemory. The issues related to refactoring cxdb are #16.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type DepositStore

type DepositStore interface {
	// RegisterUser takes in a pubkey, and an address for the pubkey
	RegisterUser(pubkey *koblitz.PublicKey, address string) (err error)
	// UpdateDeposits updates the deposits when a block comes in
	UpdateDeposits(deposits []match.Deposit, blockheight uint64) (depositExecs []*match.SettlementExecution, err error)
	// GetDepositAddressMap gets a map of the deposit addresses we own to pubkeys
	GetDepositAddressMap() (depAddrMap map[string]*koblitz.PublicKey, err error)
	// GetDepositAddress gets the deposit address for a pubkey and an asset.
	GetDepositAddress(pubkey *koblitz.PublicKey) (addr string, err error)
}

type PuzzleStore

type PuzzleStore interface {
	// ViewAuctionPuzzleBook takes in an auction ID, and returns encrypted auction orders, and puzzles.
	// You don't know what auction IDs should be in the orders encrypted in the puzzle book, but this is
	// what was submitted.
	ViewAuctionPuzzleBook(auctionID *match.AuctionID) (puzzles []*match.EncryptedAuctionOrder, err error)
	// PlaceAuctionPuzzle puts an encrypted auction order in the datastore.
	PlaceAuctionPuzzle(puzzledOrder *match.EncryptedAuctionOrder) (err error)
}

PuzzleStore is an interface for defining a storage layer for auction order puzzles.

type SettlementStore

type SettlementStore interface {
	// UpdateBalances updates the balances from the settlement executions
	UpdateBalances(settlementExecs []*match.SettlementResult) (err error)
	// GetBalance gets the balance for a pubkey and an asset.
	GetBalance(pubkey *koblitz.PublicKey) (balance uint64, err error)
}

SettlementStore is like a frontend for settlements, it contains balances that are readable

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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