cxauctionserver

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

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CreateAuctionBatcherMap

func CreateAuctionBatcherMap(pairList []*match.Pair, maxBatchSize uint64) (batchers map[match.Pair]match.AuctionBatcher, err error)

Types

type ABatcher

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

ABather is a very simple, small scale, non-persistent batcher.

func NewABatcher

func NewABatcher(maxBatchSize uint64) (batcher *ABatcher, err error)

NewABatcher creates a new AuctionBatcher.

func (*ABatcher) ActiveAuctions

func (ab *ABatcher) ActiveAuctions() (activeBatches map[[32]byte]time.Time)

ActiveAuctions returns a map of auction id to time

func (*ABatcher) AddEncrypted

func (ab *ABatcher) AddEncrypted(order *match.EncryptedAuctionOrder) (err error)

AddEncrypted adds an encrypted order to an auction. This should error if either the auction doesn't exist, or the auction is ended.

func (*ABatcher) EndAuction

func (ab *ABatcher) EndAuction(auctionID [32]byte) (batchChan chan *match.AuctionBatch, err error)

EndAuction ends the auction with the specified auction ID, and returns the channel which will receive a batch of orders puzzle results. This is like a promise. This channel should be of size 1. TODO: add commitment to this?

func (*ABatcher) RegisterAuction

func (ab *ABatcher) RegisterAuction(auctionID [32]byte) (err error)

RegisterAuction registers a new auction with a specified Auction ID, which will be an array of 32 bytes.

type OpencxAuctionServer

type OpencxAuctionServer struct {
	SettlementEngines map[*coinparam.Params]match.SettlementEngine
	MatchingEngines   map[match.Pair]match.AuctionEngine
	Orderbooks        map[match.Pair]match.AuctionOrderbook
	PuzzleEngines     map[match.Pair]cxdb.PuzzleStore
	OrderBatchers     map[match.Pair]match.AuctionBatcher
	// contains filtered or unexported fields
}

OpencxAuctionServer is what will hopefully help handle and manage the auction logic, rpc, and db

func InitServer

func InitServer(setEngines map[*coinparam.Params]match.SettlementEngine, matchEngines map[match.Pair]match.AuctionEngine, books map[match.Pair]match.AuctionOrderbook, pzengines map[match.Pair]cxdb.PuzzleStore, batchers map[match.Pair]match.AuctionBatcher, orderChanSize uint64, standardAuctionTime uint64) (server *OpencxAuctionServer, err error)

InitServer creates a new server

func InitServerMemoryDefault

func InitServerMemoryDefault(coinList []*coinparam.Params, orderChanSize uint64, standardAuctionTime uint64, maxBatchSize uint64) (server *OpencxAuctionServer, err error)

InitServerMemoryDefault initializes an auction server with in memory auction engines, settlement engines, and puzzle stores

func InitServerSQLDefault

func InitServerSQLDefault(coinList []*coinparam.Params, orderChanSize uint64, standardAuctionTime uint64, maxBatchSize uint64) (server *OpencxAuctionServer, err error)

InitServerSQLDefault initializes an auction server with SQL engines, orderbooks, and puzzle stores. This generates everything using built in methods

func (*OpencxAuctionServer) AuctionClock

func (s *OpencxAuctionServer) AuctionClock(pair match.Pair, startID [32]byte)

AuctionClock should be run in a goroutine and just commit to puzzles after some time What this does is first makes a channel called doneChan. This channel keeps track of the time that each auction is committed to.

func (*OpencxAuctionServer) CommitOrdersNewAuction

func (s *OpencxAuctionServer) CommitOrdersNewAuction(pair *match.Pair, auctionID [32]byte) (newID [32]byte, err error)

CommitOrdersNewAuction commits to a set of encrypted orders and changes the auction ID. TODO: figure out how to broadcast these, and where to store them, if we need to store them also TODO: REWRITE because batcher is a better way of doing things

func (*OpencxAuctionServer) CurrentAuctionTime

func (s *OpencxAuctionServer) CurrentAuctionTime() (currentAuctionTime uint64, err error)

CurrentAuctionTime gets the current auction time

func (*OpencxAuctionServer) EndAuctionWithID

func (s *OpencxAuctionServer) EndAuctionWithID(pair *match.Pair, auctionID [32]byte) (result *match.AuctionBatch, err error)

EndAuctionWithID ends an auction for a certain pair with a specific ID, waiting for the auction to end. This is blocking, returning the result of the auction.

func (*OpencxAuctionServer) GetIDTimeFromPair

func (s *OpencxAuctionServer) GetIDTimeFromPair(pair *match.Pair) (id [32]byte, recent time.Time, err error)

GetIDTimeFromPair gets the most recent auction ID and its start time

func (*OpencxAuctionServer) PlaceBatch

func (s *OpencxAuctionServer) PlaceBatch(batch *match.AuctionBatch) (err error)

func (*OpencxAuctionServer) PlacePuzzledOrder

func (s *OpencxAuctionServer) PlacePuzzledOrder(order *match.EncryptedAuctionOrder) (err error)

func (*OpencxAuctionServer) PlacePuzzledOrderAsync

func (s *OpencxAuctionServer) PlacePuzzledOrderAsync(order *match.EncryptedAuctionOrder, errChan chan error)

PlacePuzzledOrder places a timelock encrypted order. It also starts to decrypt the order in a goroutine.

func (*OpencxAuctionServer) StartAuctionWithID

func (s *OpencxAuctionServer) StartAuctionWithID(pair *match.Pair, auctionID [32]byte) (err error)

StartAuctionWithID starts an auction for a certain pair with a specific ID

func (*OpencxAuctionServer) StartClockRandomAuction

func (s *OpencxAuctionServer) StartClockRandomAuction() (err error)

func (*OpencxAuctionServer) StopClock

func (s *OpencxAuctionServer) StopClock() (err error)

StopClock stops the server clock

func (*OpencxAuctionServer) StopClockAndWait

func (s *OpencxAuctionServer) StopClockAndWait() (err error)

StopClockAndWait stops the clock and ends, waits for all active auctions to finish

Jump to

Keyboard shortcuts

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