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

	var tx *sql.Tx
	if tx, err = db.DBHandler.Begin(); err != nil {
		err = fmt.Errorf("Error when beginning transaction for NewAuction: %s", err)
		return
	}

	defer func() {
		if err != nil {
			tx.Rollback()
			err = fmt.Errorf("Error while placing puzzle order: \n%s", err)
			return
		}
		err = tx.Commit()
	}()

	// We don't really care about the result when trying to use a schema
	if _, err = tx.Exec("USE " + db.puzzleSchema + ";"); err != nil {
		err = fmt.Errorf("Error trying to use auction schema: %s", err)
		return
	}

	var orderBytes []byte
	if orderBytes, err = encryptedOrder.Serialize(); err != nil {
		err = fmt.Errorf("Error serializing order: %s", err)
		return
	}

	// We concatenate ciphertext and puzzle and set "selected" to 1 by default
	placeAuctionPuzzleQuery := fmt.Sprintf("INSERT INTO %s VALUES ('%x', '%x', 1);", db.puzzleTable, orderBytes, encryptedOrder.IntendedAuction)
	if _, err = tx.Exec(placeAuctionPuzzleQuery); err != nil {
		err = fmt.Errorf("Error adding auction puzzle to puzzle orders: %s", err)
		return
	}

	return
}
// PlaceAuctionPuzzle puts a puzzle and ciphertext in the datastore.
PlaceAuctionPuzzle puts a puzzle and ciphertext in the datastore.
// PlaceAuctionPuzzle puts a puzzle and ciphertext in the datastore .
func (db *DB) PlaceAuctionPuzzle(encryptedOrder *match.EncryptedAuctionOrder) (err error) {
	var tx *sql.Tx
	if tx, err = db.DBHandler.Begin(); err != nil {
		err = fmt.Errorf("Error when beginning transaction for NewAuction: %s", err)
		return
	}
	defer func() {
		if err != nil {
			tx.Rollback()
			err = fmt.Errorf("Error while placing puzzle order: \n%s", err)
			return
		}
		err = tx.Commit()
	}()
	if _, err = tx.Exec("USE " + db.puzzleSchema + ";"); err != nil {
		err = fmt.Errorf("Error trying to use auction schema: %s", err)
		return
	}
	var orderBytes []byte
	if orderBytes, err = encryptedOrder.Serialize(); err != nil {
		err = fmt.Errorf("Error serializing order: %s", err)
		return
	}
	placeAuctionPuzzleQuery := fmt.Sprintf("INSERT INTO %s VALUES ('%x', '%x', 1);", db.puzzleTable, orderBytes, encryptedOrder.IntendedAuction)
	if _, err = tx.Exec(placeAuctionPuzzleQuery); err != nil {
		err = fmt.Errorf("Error adding auction puzzle to puzzle orders: %s", err)
		return
	}
	return
}
func ( db * DB ) PlaceAuctionPuzzle ( encryptedOrder * match . EncryptedAuctionOrder ) ( err error ) { var tx * sql . Tx if tx , err = db . DBHandler . Begin ( ) ; err != nil { err = fmt . Errorf ( " " , err ) return } defer func ( ) { if err != nil { tx . Rollback ( ) err = fmt . Errorf ( " \n " , err ) return } err = tx . Commit ( ) } ( ) if _ , err = tx . Exec ( " " + db . puzzleSchema + " " ) ; err != nil { err = fmt . Errorf ( " " , err ) return } var orderBytes [ ] byte if orderBytes , err = encryptedOrder . Serialize ( ) ; err != nil { err = fmt . Errorf ( " " , err ) return } placeAuctionPuzzleQuery := fmt . Sprintf ( " " , db . puzzleTable , orderBytes , encryptedOrder . IntendedAuction ) if _ , err = tx . Exec ( placeAuctionPuzzleQuery ) ; err != nil { err = fmt . Errorf ( " " , err ) return } return }
PlaceAuctionPuzzle puts a puzzle and ciphertext in the datastore.
PlaceAuctionPuzzle puts a puzzle and ciphertext in the datastore .
// We don't really care about the result when trying to use a schema // We concatenate ciphertext and puzzle and set "selected" to 1 by default