func (db *DB) NewAuction(auctionID [32]byte) (height uint64, 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 creating new auction: \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.auctionOrderSchema + ";"); err != nil {
		err = fmt.Errorf("Error trying to use auction order schema: %s", err)
		return
	}

	var nullCompatHeight sql.NullInt64
	auctionNumQuery := fmt.Sprintf("SELECT MAX(auctionNumber) FROM %s;", db.auctionOrderTable)
	if err = tx.QueryRow(auctionNumQuery).Scan(&nullCompatHeight); err != nil {
		err = fmt.Errorf("Could not find maximum auction number when creating new auction: %s", err)
		return
	}

	if nullCompatHeight.Valid {
		height = uint64(nullCompatHeight.Int64)
	} else {
		logging.Warnf("Warning, the max height was null!")
	}

	// Insert the new auction ID w/ current max height + 1
	height++
	insertNewAuctionQuery := fmt.Sprintf("INSERT INTO %s VALUES ('%x', %d);", db.auctionOrderTable, auctionID, height)
	if _, err = tx.Exec(insertNewAuctionQuery); err != nil {
		err = fmt.Errorf("Error inserting new auction ID when creating new auction: %s", err)
		return
	}

	return
}
// NewAuction takes in an auction ID, and creates a new auction, returning the "height"
// of the auction.
NewAuction takes in an auction ID, and creates a new auction, returning the "height"
of the auction.
// NewAuction takes in an auction ID and creates a new auction returning the " height " // of the auction .
func (db *DB) NewAuction(auctionID [32]byte) (height uint64, 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 creating new auction: \n%s", err)
			return
		}
		err = tx.Commit()
	}()
	if _, err = tx.Exec("USE " + db.auctionOrderSchema + ";"); err != nil {
		err = fmt.Errorf("Error trying to use auction order schema: %s", err)
		return
	}
	var nullCompatHeight sql.NullInt64
	auctionNumQuery := fmt.Sprintf("SELECT MAX(auctionNumber) FROM %s;", db.auctionOrderTable)
	if err = tx.QueryRow(auctionNumQuery).Scan(&nullCompatHeight); err != nil {
		err = fmt.Errorf("Could not find maximum auction number when creating new auction: %s", err)
		return
	}
	if nullCompatHeight.Valid {
		height = uint64(nullCompatHeight.Int64)
	} else {
		logging.Warnf("Warning, the max height was null!")
	}
	height++
	insertNewAuctionQuery := fmt.Sprintf("INSERT INTO %s VALUES ('%x', %d);", db.auctionOrderTable, auctionID, height)
	if _, err = tx.Exec(insertNewAuctionQuery); err != nil {
		err = fmt.Errorf("Error inserting new auction ID when creating new auction: %s", err)
		return
	}
	return
}
func ( db * DB ) NewAuction ( auctionID [ 32 ] byte ) ( height uint64 , 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 . auctionOrderSchema + " " ) ; err != nil { err = fmt . Errorf ( " " , err ) return } var nullCompatHeight sql . NullInt64 auctionNumQuery := fmt . Sprintf ( " " , db . auctionOrderTable ) if err = tx . QueryRow ( auctionNumQuery ) . Scan ( & nullCompatHeight ) ; err != nil { err = fmt . Errorf ( " " , err ) return } if nullCompatHeight . Valid { height = uint64 ( nullCompatHeight . Int64 ) } else { logging . Warnf ( " " ) } height ++ insertNewAuctionQuery := fmt . Sprintf ( " " , db . auctionOrderTable , auctionID , height ) if _ , err = tx . Exec ( insertNewAuctionQuery ) ; err != nil { err = fmt . Errorf ( " " , err ) return } return }
NewAuction takes in an auction ID, and creates a new auction, returning the "height"
of the auction.
NewAuction takes in an auction ID and creates a new auction returning the " height " of the auction .
// We don't really care about the result when trying to use a schema // Insert the new auction ID w/ current max height + 1