cxdbmemory

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: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CreateAuctionEngineMap

func CreateAuctionEngineMap(pairList []*match.Pair) (mengines map[match.Pair]match.AuctionEngine, err error)

func CreateAuctionOrderbook

func CreateAuctionOrderbook(pair *match.Pair) (book match.AuctionOrderbook, err error)

CreateAuctionOrderbook creates a auction orderbook based on a pair

func CreateAuctionOrderbookMap

func CreateAuctionOrderbookMap(pairList []*match.Pair) (aucMap map[match.Pair]match.AuctionOrderbook, err error)

CreateAuctionOrderbookMap creates a map of pair to auction engine, given a list of pairs.

func CreatePinkySwearEngine

func CreatePinkySwearEngine(coin *coinparam.Params, whitelist [][33]byte, acceptAll bool) (engine match.SettlementEngine, err error)

CreatePinkySwearEngine creates a "pinky swear" engine for a specific coin

func CreatePinkySwearEngineMap

func CreatePinkySwearEngineMap(whitelistMap map[*coinparam.Params][][33]byte, acceptAll bool) (setMap map[*coinparam.Params]match.SettlementEngine, err error)

CreatePinkySwearEngineMap creates a map of coin to settlement engine, given a map of coins to whitelists. This creates pinky swear settlement engines, so beware because those let anyone on the whitelist do settlement. acceptAll will just accept all, pretty much ignores the whitelist

func CreatePuzzleStore

func CreatePuzzleStore(pair *match.Pair) (store cxdb.PuzzleStore, err error)

CreatePuzzleStore creates a puzzle store for a specific coin.

func CreatePuzzleStoreMap

func CreatePuzzleStoreMap(pairList []*match.Pair) (pzMap map[match.Pair]cxdb.PuzzleStore, err error)

CreatePuzzleStoreMap creates a map of pair to pair list, given a list of pairs.

func CreateSettlementEngine

func CreateSettlementEngine(coin *coinparam.Params) (engine match.SettlementEngine, err error)

CreateSettlementEngine creates a settlement engine for a specific coin

func CreateSettlementEngineMap

func CreateSettlementEngineMap(coins []*coinparam.Params) (setMap map[*coinparam.Params]match.SettlementEngine, err error)

CreateSettlementEngineMap creates a map of coin to settlement engine, given a list of coins.

Types

type CXDBMemory

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

CXDBMemory is a super basic data store that just uses golang types for everything there's no persistence, it's just used to build out the outer layers of a feature before the persistent database details are worked out

func (*CXDBMemory) AddToBalance

func (db *CXDBMemory) AddToBalance(pubkey *koblitz.PublicKey, amount uint64, coin *coinparam.Params) (err error)

AddToBalance adds to the balance of a user

func (*CXDBMemory) GetBalance

func (db *CXDBMemory) GetBalance(pubkey *koblitz.PublicKey, coin *coinparam.Params) (amount uint64, err error)

GetBalance gets the balance for a pubkey and an asset.

func (*CXDBMemory) NewAuction

func (db *CXDBMemory) NewAuction(auctionID [32]byte) (height uint64, err error)

NewAuction takes in an auction ID, and creates a new auction, returning the "height" of the auction.

func (*CXDBMemory) PlaceAuctionOrder

func (db *CXDBMemory) PlaceAuctionOrder(order *match.AuctionOrder) (err error)

PlaceAuctionOrder places an order in the unencrypted datastore.

func (*CXDBMemory) PlaceAuctionPuzzle

func (db *CXDBMemory) PlaceAuctionPuzzle(encryptedOrder *match.EncryptedAuctionOrder) (err error)

PlaceAuctionPuzzle puts a puzzle and ciphertext in the datastore.

func (*CXDBMemory) RegisterUser

func (db *CXDBMemory) RegisterUser(pubkey *koblitz.PublicKey, addressMap map[*coinparam.Params]string) (err error)

RegisterUser takes in a pubkey, and a map of asset to addresses for the pubkey. It inserts the necessary information in databases to register the pubkey.

func (*CXDBMemory) SetupClient

func (db *CXDBMemory) SetupClient(coins []*coinparam.Params) (err error)

SetupClient makes sure that whatever things need to be done before we use the datastore can be done before we need to use the datastore.

func (*CXDBMemory) ViewAuctionOrderBook

func (db *CXDBMemory) ViewAuctionOrderBook(tradingPair *match.Pair, auctionID [32]byte) (book map[float64][]*match.AuctionOrderIDPair, err error)

ViewAuctionOrderBook takes in a trading pair and auction ID, and returns auction orders.

func (*CXDBMemory) ViewAuctionPuzzleBook

func (db *CXDBMemory) ViewAuctionPuzzleBook(auctionID [32]byte) (orders []*match.EncryptedAuctionOrder, err error)

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. This also doesn't error out because if there are no orders with the auctionID then it doesn't really matter, we just return an empty list? Maybe we should have an API method to return auctionIDs.

func (*CXDBMemory) Withdraw

func (db *CXDBMemory) Withdraw(pubkey *koblitz.PublicKey, coin *coinparam.Params, amount uint64) (err error)

Withdraw checks the user's balance against the amount and if valid, reduces the balance by that amount.

type MemoryAuctionEngine

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

func (*MemoryAuctionEngine) CancelAuctionOrder

func (me *MemoryAuctionEngine) CancelAuctionOrder(id *match.OrderID) (cancelled *match.CancelledOrder, cancelSettlement *match.SettlementExecution, err error)

CancelAuctionOrder should cancel an order for a specific order ID, and produce a response output. This response output should be used in case the matching engine dies, and this can be replayed to build the state.

func (*MemoryAuctionEngine) MatchAuctionOrders

func (me *MemoryAuctionEngine) MatchAuctionOrders(auctionID *match.AuctionID) (orderExecs []*match.OrderExecution, settlementExecs []*match.SettlementExecution, err error)

MatchAuctionOrders matches the auction orders for a specific auction ID

func (*MemoryAuctionEngine) PlaceAuctionOrder

func (me *MemoryAuctionEngine) PlaceAuctionOrder(order *match.AuctionOrder, auctionID *match.AuctionID) (idRes *match.AuctionOrderIDPair, err error)

PlaceAuctionOrder should place an order for a specific auction ID, and produce a response output. This response output should be used in case the matching engine dies, and this can be replayed to build the state. This method assumes that the auction order is valid, and has the same pair as all of the other orders that have been placed for this matching engine.

type MemoryAuctionOrderbook

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

MemoryAuctionOrderbook is the representation of a auction orderbook for SQL

func (*MemoryAuctionOrderbook) CalculatePrice

func (mo *MemoryAuctionOrderbook) CalculatePrice(auctionID *match.AuctionID) (price float64, err error)

CalculatePrice takes in a pair and returns the calculated price based on the orderbook.

func (*MemoryAuctionOrderbook) GetOrder

func (mo *MemoryAuctionOrderbook) GetOrder(orderID *match.OrderID) (aucOrder *match.AuctionOrderIDPair, err error)

GetOrder gets an order from an OrderID

func (*MemoryAuctionOrderbook) GetOrdersForPubkey

func (mo *MemoryAuctionOrderbook) GetOrdersForPubkey(pubkey *koblitz.PublicKey) (orders map[float64][]*match.AuctionOrderIDPair, err error)

GetOrdersForPubkey gets orders for a specific pubkey.

func (*MemoryAuctionOrderbook) UpdateBookCancel

func (mo *MemoryAuctionOrderbook) UpdateBookCancel(cancel *match.CancelledOrder) (err error)

UpdateBookCancel takes in an order cancellation and updates the orderbook.

func (*MemoryAuctionOrderbook) UpdateBookExec

func (mo *MemoryAuctionOrderbook) UpdateBookExec(exec *match.OrderExecution) (err error)

UpdateBookExec takes in an order execution and updates the orderbook.

func (*MemoryAuctionOrderbook) UpdateBookPlace

func (mo *MemoryAuctionOrderbook) UpdateBookPlace(auctionIDPair *match.AuctionOrderIDPair) (err error)

UpdateBookPlace takes in an order, ID, auction ID, and adds the order to the orderbook.

func (*MemoryAuctionOrderbook) ViewAuctionOrderBook

func (mo *MemoryAuctionOrderbook) ViewAuctionOrderBook() (book map[float64][]*match.AuctionOrderIDPair, err error)

ViewAuctionOrderbook takes in a trading pair and returns the orderbook as a map

type MemoryPuzzleStore

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

MemoryPuzzleStore is a puzzle store representation for an in memory database

func (*MemoryPuzzleStore) PlaceAuctionPuzzle

func (mp *MemoryPuzzleStore) PlaceAuctionPuzzle(puzzledOrder *match.EncryptedAuctionOrder) (err error)

PlaceAuctionPuzzle puts an encrypted auction order in the datastore.

func (*MemoryPuzzleStore) ViewAuctionPuzzleBook

func (mp *MemoryPuzzleStore) ViewAuctionPuzzleBook(auctionID *match.AuctionID) (puzzles []*match.EncryptedAuctionOrder, err error)

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.

type MemorySettlementEngine

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

func (*MemorySettlementEngine) ApplySettlementExecution

func (me *MemorySettlementEngine) ApplySettlementExecution(setExec *match.SettlementExecution) (setRes *match.SettlementResult, err error)

ApplySettlementExecution applies the settlementExecution, this assumes that the settlement execution is valid

func (*MemorySettlementEngine) CheckValid

func (me *MemorySettlementEngine) CheckValid(setExec *match.SettlementExecution) (valid bool, err error)

CheckValid returns true if the settlement execution would be valid

type PinkySwearEngine

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

PinkySwearEngine is a settlement engine that does not actually do any settlement. It just sort of whitelists pubkeys that can / can not make orders

func (*PinkySwearEngine) ApplySettlementExecution

func (pe *PinkySwearEngine) ApplySettlementExecution(setExec *match.SettlementExecution) (setRes *match.SettlementResult, err error)

ApplySettlementExecution applies the settlementExecution, this assumes that the settlement execution is valid

func (*PinkySwearEngine) CheckValid

func (pe *PinkySwearEngine) CheckValid(setExec *match.SettlementExecution) (valid bool, err error)

CheckValid returns true if the settlement execution would be valid

Jump to

Keyboard shortcuts

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