mirror of
https://github.com/d0zingcat/gocryptotrader.git
synced 2026-06-03 15:10:49 +00:00
Update request.go to fix concurrency nonce issues (#285)
* Updates nonce generation to adhere to fifo channel buffer before request executes by routine * removed unused variables, lns etc * Fix requested changes and added in timer that disengages lock if out of scope error occurs * Fixed woopsy daisy issue * Add benchmark, reduce time in force to unlock before stack insertion, add nil check for edge case * Remove unusued waitgroup field * use return nonce.Value and method, rm redundant nonce code, fix tests. * Fix linter issue: unnecessary conversion
This commit is contained in:
committed by
Adrian Gallagher
parent
1967507d40
commit
35b94268e0
@@ -371,7 +371,7 @@ func (e *EXMO) GetWalletHistory(date int64) (WalletHistory, error) {
|
||||
|
||||
// SendHTTPRequest sends an unauthenticated HTTP request
|
||||
func (e *EXMO) SendHTTPRequest(path string, result interface{}) error {
|
||||
return e.SendPayload(http.MethodGet, path, nil, nil, result, false, e.Verbose)
|
||||
return e.SendPayload(http.MethodGet, path, nil, nil, result, false, false, e.Verbose)
|
||||
}
|
||||
|
||||
// SendAuthenticatedHTTPRequest sends an authenticated HTTP request
|
||||
@@ -381,12 +381,8 @@ func (e *EXMO) SendAuthenticatedHTTPRequest(method, endpoint string, vals url.Va
|
||||
e.Name)
|
||||
}
|
||||
|
||||
if e.Nonce.Get() == 0 {
|
||||
e.Nonce.Set(time.Now().UnixNano())
|
||||
} else {
|
||||
e.Nonce.Inc()
|
||||
}
|
||||
vals.Set("nonce", e.Nonce.String())
|
||||
n := e.Requester.GetNonce(true).String()
|
||||
vals.Set("nonce", n)
|
||||
|
||||
payload := vals.Encode()
|
||||
hash := common.GetHMAC(common.HashSHA512,
|
||||
@@ -413,6 +409,7 @@ func (e *EXMO) SendAuthenticatedHTTPRequest(method, endpoint string, vals url.Va
|
||||
strings.NewReader(payload),
|
||||
result,
|
||||
true,
|
||||
true,
|
||||
e.Verbose)
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user