I abstracted away the "handlers" that were previously in place for puzzle solving in cxauctionserver.
This is important because it means if I want to run these batchers on a computer with more cores I can, I'd just have to make a client / server that interfaces with the code that is currently implemented for the batcher.
The implementation is ABatcher in the cxauctionserver package, and could be put into a new package on its own, but for now it doesn't really matter too much.
The interface is in match and this is the definition:
// AuctionBatcher is an interface for a service that collects orders and handles batching per auction.
// This is abstracted because solving puzzles is a task that should be easily outsourceable, and should
// not be integrated into the core logic. One could easily see a server that performs puzzle solving
// that is separate from the actual exchange. The exchange doesn't need to schedule puzzle solving,
// or worry about scaling it, but the auction batcher does. The auction batcher needs to involve solving
// many puzzles at once.
type AuctionBatcher interface {
// RegisterAuction registers a new auction with a specified Auction ID, which will be an array of
// 32 bytes.
RegisterAuction(auctionID [32]byte) (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.
AddEncrypted(order *EncryptedAuctionOrder) (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.
EndAuction(auctionID [32]byte) (batchChan chan *AuctionBatch, err error)
// ActiveAuctions returns a map of auction id to time TODO: figure out if this is really necessary
ActiveAuctions() (activeBatches map[[32]byte]time.Time)
}
I also changed the API a bit to return more useful information when requesting data about the auctions, such as the actual timestamp.
I abstracted away the "handlers" that were previously in place for puzzle solving in
cxauctionserver
. This is important because it means if I want to run these batchers on a computer with more cores I can, I'd just have to make a client / server that interfaces with the code that is currently implemented for the batcher.The implementation is
ABatcher
in thecxauctionserver
package, and could be put into a new package on its own, but for now it doesn't really matter too much.The interface is in
match
and this is the definition:I also changed the API a bit to return more useful information when requesting data about the auctions, such as the actual timestamp.