Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Lms #129

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open

Lms #129

Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 4 additions & 5 deletions utils/nonce.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ package utils

import (
"strconv"
"sync/atomic"
"time"
)

Expand All @@ -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()),
}
}

Expand All @@ -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
Expand All @@ -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)
}
2 changes: 1 addition & 1 deletion v1/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import (
"net/http"
"net/url"

"github.com/bitfinexcom/bitfinex-api-go/utils"
"github.com/blockcapital/bitfinex-api-go/utils"
)

const (
Expand Down
2 changes: 1 addition & 1 deletion v1/websocket.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import (
"net/http"
"reflect"

"github.com/bitfinexcom/bitfinex-api-go/utils"
"github.com/blockcapital/bitfinex-api-go/utils"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think some of these lines are supposed to be included. Your earlier opening of #128 indicates you might be having a bit of trouble with the github PR interface.

How about explaining what changes you are trying to submit and someone might be able to assist.


"github.com/gorilla/websocket"
)
Expand Down
3 changes: 2 additions & 1 deletion v2/rest/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -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/"
Expand Down
5 changes: 2 additions & 3 deletions v2/websocket/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down