func (s *OpencxAuctionServer) CommitOrdersNewAuction() (err error) {

	// Lock!
	s.dbLock.Lock()

	// First get the current auction ID
	var auctionID [32]byte
	if auctionID, err = s.CurrentAuctionID(); err != nil {
		s.dbLock.Unlock()
		err = fmt.Errorf("Eror getting current auction id for commit: %s", err)
		return
	}

	// Then get the puzzles
	var puzzles []*match.EncryptedAuctionOrder
	if puzzles, err = s.OpencxDB.ViewAuctionPuzzleBook(auctionID); err != nil {
		s.dbLock.Unlock()
		err = fmt.Errorf("Error getting auction puzzle book for commit: %s", err)
		return
	}

	sha3 := sha3.New256()
	// Add the current auction ID to be hashed
	sha3.Write(auctionID[:])
	// Then find the hash of the orders + the previous hash
	for _, pz := range puzzles {
		var pzRaw []byte
		if pzRaw, err = pz.Serialize(); err != nil {
			err = fmt.Errorf("Error serializing puzzle for commitment: %s", err)
			return
		}
		sha3.Write(pzRaw)
	}

	// Set the new auction ID to the hash of the orders. TODO: figure out if signing the puzzles
	// instead is a good idea, and if the dependence on the previous commitment is a good idea.
	copy(s.auctionID[:], sha3.Sum(nil))

	var height uint64
	if height, err = s.OpencxDB.NewAuction(s.auctionID); err != nil {
		err = fmt.Errorf("Error updating auction in DB while committing orders and creating new auction: %s", err)
		return
	}

	// Unlock!
	s.dbLock.Unlock()

	logging.Infof("Done creating new auction %x at height %d", auctionID, height)

	return
}
// CommitOrdersNewAuction commits to a set of decypted orders and changes the auction ID.
// TODO: figure out how to broadcast these, and where to store them, if we need to store them
CommitOrdersNewAuction commits to a set of decypted orders and changes the auction ID.
TODO: figure out how to broadcast these, and where to store them, if we need to store them
// CommitOrdersNewAuction commits to a set of decypted orders and changes the auction ID . // TODO : figure out how to broadcast these and where to store them if we need to store them
func (s *OpencxAuctionServer) CommitOrdersNewAuction() (err error) {
	s.dbLock.Lock()
	var auctionID [32]byte
	if auctionID, err = s.CurrentAuctionID(); err != nil {
		s.dbLock.Unlock()
		err = fmt.Errorf("Eror getting current auction id for commit: %s", err)
		return
	}
	var puzzles []*match.EncryptedAuctionOrder
	if puzzles, err = s.OpencxDB.ViewAuctionPuzzleBook(auctionID); err != nil {
		s.dbLock.Unlock()
		err = fmt.Errorf("Error getting auction puzzle book for commit: %s", err)
		return
	}
	sha3 := sha3.New256()
	sha3.Write(auctionID[:])
	for _, pz := range puzzles {
		var pzRaw []byte
		if pzRaw, err = pz.Serialize(); err != nil {
			err = fmt.Errorf("Error serializing puzzle for commitment: %s", err)
			return
		}
		sha3.Write(pzRaw)
	}
	copy(s.auctionID[:], sha3.Sum(nil))
	var height uint64
	if height, err = s.OpencxDB.NewAuction(s.auctionID); err != nil {
		err = fmt.Errorf("Error updating auction in DB while committing orders and creating new auction: %s", err)
		return
	}
	s.dbLock.Unlock()
	logging.Infof("Done creating new auction %x at height %d", auctionID, height)
	return
}
func ( s * OpencxAuctionServer ) CommitOrdersNewAuction ( ) ( err error ) { s . dbLock . Lock ( ) var auctionID [ 32 ] byte if auctionID , err = s . CurrentAuctionID ( ) ; err != nil { s . dbLock . Unlock ( ) err = fmt . Errorf ( " " , err ) return } var puzzles [ ] * match . EncryptedAuctionOrder if puzzles , err = s . OpencxDB . ViewAuctionPuzzleBook ( auctionID ) ; err != nil { s . dbLock . Unlock ( ) err = fmt . Errorf ( " " , err ) return } sha3 := sha3 . New256 ( ) sha3 . Write ( auctionID [ : ] ) for _ , pz := range puzzles { var pzRaw [ ] byte if pzRaw , err = pz . Serialize ( ) ; err != nil { err = fmt . Errorf ( " " , err ) return } sha3 . Write ( pzRaw ) } copy ( s . auctionID [ : ] , sha3 . Sum ( nil ) ) var height uint64 if height , err = s . OpencxDB . NewAuction ( s . auctionID ) ; err != nil { err = fmt . Errorf ( " " , err ) return } s . dbLock . Unlock ( ) logging . Infof ( " " , auctionID , height ) return }
CommitOrdersNewAuction commits to a set of decypted orders and changes the auction ID.
CommitOrdersNewAuction commits to a set of decypted orders and changes the auction ID .
// Lock! // First get the current auction ID // Then get the puzzles // Add the current auction ID to be hashed // Then find the hash of the orders + the previous hash // Set the new auction ID to the hash of the orders. TODO: figure out if signing the puzzles // instead is a good idea, and if the dependence on the previous commitment is a good idea. // Unlock!