diff --git a/utils/nonce.go b/utils/nonce.go index 13af9bde8..a9d0501f4 100644 --- a/utils/nonce.go +++ b/utils/nonce.go @@ -2,7 +2,6 @@ package utils import ( "strconv" - "sync/atomic" "time" ) @@ -22,12 +21,12 @@ type EpochNonceGenerator struct { // key and as such needs to be synchronised with other instances using the same // key in order to avoid race conditions. func (u *EpochNonceGenerator) GetNonce() string { - return strconv.FormatUint(atomic.AddUint64(&u.nonce, 1), 10) + return strconv.FormatInt(time.Now().UnixNano(), 10) } func NewEpochNonceGenerator() *EpochNonceGenerator { return &EpochNonceGenerator{ - nonce: uint64(time.Now().Unix()) * 1000, + nonce: uint64(time.Now().UnixNano()), } } @@ -36,7 +35,7 @@ func NewEpochNonceGenerator() *EpochNonceGenerator { var nonce uint64 func init() { - nonce = uint64(time.Now().Unix()) * 1000 + nonce = uint64(time.Now().UnixNano()) } // GetNonce is a naive nonce producer that takes the current Unix nano epoch @@ -45,5 +44,5 @@ func init() { // key and as such needs to be synchronised with other instances using the same // key in order to avoid race conditions. func GetNonce() string { - return strconv.FormatUint(atomic.AddUint64(&nonce, 1), 10) + return strconv.FormatInt(time.Now().UnixNano(), 10) } diff --git a/v1/client.go b/v1/client.go index 375193eba..3c2581dfb 100644 --- a/v1/client.go +++ b/v1/client.go @@ -12,7 +12,7 @@ import ( "net/http" "net/url" - "github.com/bitfinexcom/bitfinex-api-go/utils" + "github.com/blockcapital/bitfinex-api-go/utils" ) const ( diff --git a/v1/websocket.go b/v1/websocket.go index 4b418d447..aa46d1d79 100644 --- a/v1/websocket.go +++ b/v1/websocket.go @@ -8,7 +8,7 @@ import ( "net/http" "reflect" - "github.com/bitfinexcom/bitfinex-api-go/utils" + "github.com/blockcapital/bitfinex-api-go/utils" "github.com/gorilla/websocket" ) diff --git a/v2/rest/client.go b/v2/rest/client.go index 640691198..94014756e 100644 --- a/v2/rest/client.go +++ b/v2/rest/client.go @@ -6,11 +6,12 @@ import ( "encoding/hex" "encoding/json" "fmt" - "github.com/bitfinexcom/bitfinex-api-go/utils" "io" "io/ioutil" "net/http" "net/url" + + "github.com/blockcapital/bitfinex-api-go/utils" ) var productionBaseURL = "https://api.bitfinex.com/v2/" diff --git a/v2/websocket/client.go b/v2/websocket/client.go index f79c7f848..25efddda4 100644 --- a/v2/websocket/client.go +++ b/v2/websocket/client.go @@ -10,13 +10,12 @@ import ( "time" "unicode" - "github.com/bitfinexcom/bitfinex-api-go/utils" + "github.com/blockcapital/bitfinex-api-go/utils" + bitfinex "github.com/blockcapital/bitfinex-api-go/v2" "crypto/hmac" "crypto/sha512" "encoding/hex" - - "github.com/bitfinexcom/bitfinex-api-go/v2" ) var productionBaseURL = "wss://api.bitfinex.com/ws/2"