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:
Ryan O'Hara-Reid
2017-08-31 16:01:28 +10:00
parent 3240a1657e
commit f27472269c
8 changed files with 1261 additions and 346 deletions

View File

@@ -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)
}