diff --git a/exchanges/nonce/nonce.go b/exchanges/nonce/nonce.go index 74916668..7f9bf964 100644 --- a/exchanges/nonce/nonce.go +++ b/exchanges/nonce/nonce.go @@ -3,14 +3,14 @@ package nonce import ( "strconv" "sync" + "sync/atomic" "time" ) // Nonce struct holds the nonce value type Nonce struct { // Standard nonce - n int64 - mtx sync.Mutex + n int64 // Hash table exclusive exchange specific nonce values boundedCall map[string]int64 boundedMtx sync.Mutex @@ -18,39 +18,28 @@ type Nonce struct { // Inc increments the nonce value func (n *Nonce) Inc() { - n.mtx.Lock() - n.n++ - n.mtx.Unlock() + atomic.AddInt64(&n.n, 1) } // Get retrives the nonce value func (n *Nonce) Get() int64 { - n.mtx.Lock() - defer n.mtx.Unlock() - return n.n + return atomic.LoadInt64(&n.n) } // GetInc increments and returns the value of the nonce func (n *Nonce) GetInc() int64 { - n.mtx.Lock() - defer n.mtx.Unlock() - n.n++ - return n.n + n.Inc() + return n.Get() } // Set sets the nonce value func (n *Nonce) Set(val int64) { - n.mtx.Lock() - n.n = val - n.mtx.Unlock() + atomic.StoreInt64(&n.n, val) } // String returns a string version of the nonce func (n *Nonce) String() string { - n.mtx.Lock() - result := strconv.FormatInt(n.n, 10) - n.mtx.Unlock() - return result + return strconv.FormatInt(n.Get(), 10) } // Value is a return type for GetValue diff --git a/exchanges/okgroup/okgroup_types.go b/exchanges/okgroup/okgroup_types.go index 4fb08915..4230c05f 100644 --- a/exchanges/okgroup/okgroup_types.go +++ b/exchanges/okgroup/okgroup_types.go @@ -183,7 +183,7 @@ type CancelSpotOrderRequest struct { // CancelSpotOrderResponse response data for CancelSpotOrder type CancelSpotOrderResponse struct { ClientOID string `json:"client_oid"` - OrderID int64 `json:"order_id"` + OrderID int64 `json:"order_id,string"` Result bool `json:"result"` } diff --git a/exchanges/zb/zb_types.go b/exchanges/zb/zb_types.go index f35e5a31..78b80962 100644 --- a/exchanges/zb/zb_types.go +++ b/exchanges/zb/zb_types.go @@ -36,13 +36,13 @@ type AccountsBaseResponse struct { // Order is the order details for retrieving all orders type Order struct { Currency string `json:"currency"` - ID int64 `json:"id"` - Price int `json:"price"` + ID int64 `json:"id,string"` + Price float64 `json:"price"` Status int `json:"status"` TotalAmount float64 `json:"total_amount"` TradeAmount int `json:"trade_amount"` TradeDate int `json:"trade_date"` - TradeMoney int `json:"trade_money"` + TradeMoney float64 `json:"trade_money"` Type int64 `json:"type"` }