(Engine) Variety of engine updates (#390)

* drop common uuid v4 func and imported package as needed

* removed common functions regarding json marshal and unmarshal and used the json package directly. WRT unmarshal it was calling reflect and converted to string which is also checked in the JSON package so it was doing a double up, this will be a tiny gain as it was directly used in the requester package for all our outbound requests.

* add in string

* explicitly throw away return error value

* atleast return the error that websocket initialise returns

* return error when not connected

* fix comment

* Adds comments

* move package declarations

* drop append whenever we call supported

* remove unused import

* Change incorrect spelling

* fix tests

* fix go import issue
This commit is contained in:
Ryan O'Hara-Reid
2019-12-03 10:06:08 +11:00
committed by Adrian Gallagher
parent c27b8657e2
commit 0c5d75b22c
70 changed files with 393 additions and 462 deletions

View File

@@ -2,6 +2,7 @@ package btcmarkets
import (
"bytes"
"encoding/json"
"errors"
"fmt"
"net/http"
@@ -391,7 +392,7 @@ func (b *BTCMarkets) SendAuthenticatedRequest(reqType, path string, data, result
payload := []byte("")
if data != nil {
payload, err = common.JSONEncode(data)
payload, err = json.Marshal(data)
if err != nil {
return err
}

View File

@@ -1,13 +1,13 @@
package btcmarkets
import (
"encoding/json"
"errors"
"fmt"
"net/http"
"strconv"
"github.com/gorilla/websocket"
"github.com/thrasher-corp/gocryptotrader/common"
"github.com/thrasher-corp/gocryptotrader/currency"
"github.com/thrasher-corp/gocryptotrader/exchanges/asset"
"github.com/thrasher-corp/gocryptotrader/exchanges/orderbook"
@@ -58,7 +58,7 @@ func (b *BTCMarkets) WsHandleData() {
}
b.Websocket.TrafficAlert <- struct{}{}
var wsResponse WsMessageType
err = common.JSONDecode(resp.Raw, &wsResponse)
err = json.Unmarshal(resp.Raw, &wsResponse)
if err != nil {
b.Websocket.DataHandler <- err
continue
@@ -70,7 +70,7 @@ func (b *BTCMarkets) WsHandleData() {
}
case "orderbook":
var ob WsOrderbook
err := common.JSONDecode(resp.Raw, &ob)
err := json.Unmarshal(resp.Raw, &ob)
if err != nil {
b.Websocket.DataHandler <- err
continue
@@ -131,7 +131,7 @@ func (b *BTCMarkets) WsHandleData() {
}
case "trade":
var trade WsTrade
err := common.JSONDecode(resp.Raw, &trade)
err := json.Unmarshal(resp.Raw, &trade)
if err != nil {
b.Websocket.DataHandler <- err
continue
@@ -147,7 +147,7 @@ func (b *BTCMarkets) WsHandleData() {
}
case "tick":
var tick WsTick
err := common.JSONDecode(resp.Raw, &tick)
err := json.Unmarshal(resp.Raw, &tick)
if err != nil {
b.Websocket.DataHandler <- err
continue
@@ -168,7 +168,7 @@ func (b *BTCMarkets) WsHandleData() {
}
case "error":
var wsErr WsError
err := common.JSONDecode(resp.Raw, &wsErr)
err := json.Unmarshal(resp.Raw, &wsErr)
if err != nil {
b.Websocket.DataHandler <- err
continue