diff --git a/goatherd.go b/goatherd.go index e702293ef0db179b964117ed238934a052bc2f04..c1ba52d9c8a1766bb08121c2f0194407a15ce1da 100644 --- a/goatherd.go +++ b/goatherd.go @@ -173,12 +173,14 @@ func transaction_failed(err error) bool { // Retrieve secret and count for given username and try to find a match within // the lookahead range. Update count in DB if match is found. All within a // transaction, retrying if it fails. -func check_offer(db *sql.DB, remote net.Addr, name string, offer string) (ok bool, err error) { +func check_offer(db *sql.DB, remote string, name string, offer string) (bool, error) { for { debugf("[%v] begin transaction", remote) tx, err := db.Begin() err_panic(err) + ok := false + debugf("[%v] looking up data for %v", remote, name) hotp, err := get_otp(tx, name) if transaction_failed(err) { @@ -207,8 +209,6 @@ func check_offer(db *sql.DB, remote net.Addr, name string, offer string) (ok boo } } - ok = false - commit: debugf("[%v] commiting", remote) err = tx.Commit()