mirror of
https://github.com/d0zingcat/gocryptotrader.git
synced 2026-06-03 15:10:49 +00:00
Fixed minor linter issues in coinut. Fixed linter issues, increased code cov & expanded functionality in gdax. Added new function in nonce package.
This commit is contained in:
@@ -3,6 +3,7 @@ package nonce
|
||||
import (
|
||||
"strconv"
|
||||
"sync"
|
||||
"time"
|
||||
)
|
||||
|
||||
// Nonce struct holds the nonce value
|
||||
@@ -47,3 +48,15 @@ func (n *Nonce) String() string {
|
||||
n.mtx.Unlock()
|
||||
return result
|
||||
}
|
||||
|
||||
// Evaluate returns a nonce while evaluating in a single locked call
|
||||
func (n *Nonce) Evaluate() string {
|
||||
n.mtx.Lock()
|
||||
defer n.mtx.Unlock()
|
||||
if n.n == 0 {
|
||||
n.n = time.Now().Unix()
|
||||
return strconv.FormatInt(n.n, 10)
|
||||
}
|
||||
n.n = n.n + 1
|
||||
return strconv.FormatInt(n.n, 10)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user