New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

remove lock #13

Merged
merged 1 commit into from Oct 20, 2018
Jump to file or symbol
Failed to load files and symbols.
+4 −7
Diff settings

Always

Just for now

@@ -43,7 +43,7 @@ func getOpenOrderByID(tx *sql.Tx, id int64) (*Order, error) {
if order.ClosedAt != nil {
return nil, ErrOrderAlreadyClosed
}
order.User, err = getUserByIDWithLock(tx, order.UserID)
order.User, err = GetUserByID(tx, order.UserID)
if err != nil {
return nil, errors.Wrap(err, "getUserByIDWithLock sell user")
}
@@ -85,11 +85,12 @@ func AddOrder(tx *sql.Tx, ot string, userID, amount, price int64) (*Order, error
if amount <= 0 || price <= 0 {
return nil, ErrParameterInvalid
}
user, err := getUserByIDWithLock(tx, userID)
user, err := GetUserByID(tx, userID)
if err != nil {
return nil, errors.Wrapf(err, "getUserByIDWithLock failed. id:%d", userID)
}
bank, err := Isubank(tx)
if err != nil {
return nil, errors.Wrap(err, "newIsubank failed")
}
@@ -131,7 +132,7 @@ func AddOrder(tx *sql.Tx, ot string, userID, amount, price int64) (*Order, error
}
func DeleteOrder(tx *sql.Tx, userID, orderID int64, reason string) error {
user, err := getUserByIDWithLock(tx, userID)
user, err := GetUserByID(tx, userID)
if err != nil {
return errors.Wrapf(err, "getUserByIDWithLock failed. id:%d", userID)
}
@@ -21,10 +21,6 @@ func GetUserByID(d QueryExecutor, id int64) (*User, error) {
return scanUser(d.Query("SELECT * FROM user WHERE id = ?", id))
}
func getUserByIDWithLock(tx *sql.Tx, id int64) (*User, error) {
return scanUser(tx.Query("SELECT * FROM user WHERE id = ? FOR UPDATE", id))
}
func UserSignup(tx *sql.Tx, name, bankID, password string) error {
bank, err := Isubank(tx)
if err != nil {
ProTip! Use n and p to navigate between commits in a pull request.