mirror of
https://github.com/d0zingcat/gocryptotrader.git
synced 2026-05-18 15:10:03 +00:00
Fixed merge issues, fixed race condition in gemini package.
This commit is contained in:
@@ -306,13 +306,7 @@ func SendHTTPGetRequest(url string, jsonDecode, isVerbose bool, result interface
|
||||
}
|
||||
|
||||
if res.StatusCode != 200 {
|
||||
<<<<<<< dae90a2eaa109648bdb85f8298d805e00ad4e974
|
||||
log.Printf("HTTP status code: %d\n", res.StatusCode)
|
||||
log.Printf("URL: %s\n", url)
|
||||
return errors.New("status code was not 200")
|
||||
=======
|
||||
return fmt.Errorf("common.SendHTTPGetRequest() error: HTTP status code %d", res.StatusCode)
|
||||
>>>>>>> In the common package added JSONDecode error check. Added verbosity in SendHTTPGetRequest. Updated Nonce package function. Fixed issues in ItBit package and expanded test coverage.
|
||||
}
|
||||
|
||||
contents, err := ioutil.ReadAll(res.Body)
|
||||
|
||||
@@ -7,6 +7,7 @@ import (
|
||||
"net/url"
|
||||
"strconv"
|
||||
"strings"
|
||||
"sync"
|
||||
"time"
|
||||
|
||||
"github.com/thrasher-/gocryptotrader/common"
|
||||
@@ -71,10 +72,13 @@ var (
|
||||
// needed append the sandbox function as well.
|
||||
type Gemini struct {
|
||||
exchange.Base
|
||||
M sync.Mutex
|
||||
}
|
||||
|
||||
// AddSession adds a new session to the gemini base
|
||||
func (g *Gemini) AddSession(sessionID int, apiKey, apiSecret, role string, needsHeartbeat bool) error {
|
||||
g.M.Lock()
|
||||
defer g.M.Unlock()
|
||||
if sessionAPIKey == nil {
|
||||
IsSession = true
|
||||
sessionAPIKey = make(map[int]string)
|
||||
@@ -139,6 +143,8 @@ func (g *Gemini) Setup(exch config.ExchangeConfig) {
|
||||
// Session is a session manager for differing APIKeys and roles, use this for all function
|
||||
// calls in this package
|
||||
func (g *Gemini) Session(sessionID int) *Gemini {
|
||||
g.M.Lock()
|
||||
defer g.M.Unlock()
|
||||
g.APIUrl = geminiAPIURL
|
||||
_, ok := sessionAPIKey[sessionID]
|
||||
if !ok {
|
||||
|
||||
@@ -94,7 +94,7 @@ func (w *WEX) GetFee() float64 {
|
||||
func (w *WEX) GetInfo() (Info, error) {
|
||||
req := fmt.Sprintf("%s/%s/%s/", wexAPIPublicURL, wexAPIPublicVersion, wexInfo)
|
||||
resp := Info{}
|
||||
err := common.SendHTTPGetRequest(req, true, &resp)
|
||||
err := common.SendHTTPGetRequest(req, true, w.Verbose, &resp)
|
||||
|
||||
if err != nil {
|
||||
return resp, err
|
||||
@@ -111,7 +111,7 @@ func (w *WEX) GetTicker(symbol string) (map[string]Ticker, error) {
|
||||
|
||||
response := Response{}
|
||||
req := fmt.Sprintf("%s/%s/%s/%s", wexAPIPublicURL, wexAPIPublicVersion, wexTicker, symbol)
|
||||
err := common.SendHTTPGetRequest(req, true, &response.Data)
|
||||
err := common.SendHTTPGetRequest(req, true, w.Verbose, &response.Data)
|
||||
|
||||
if err != nil {
|
||||
return nil, err
|
||||
@@ -128,7 +128,7 @@ func (w *WEX) GetDepth(symbol string) (Orderbook, error) {
|
||||
response := Response{}
|
||||
req := fmt.Sprintf("%s/%s/%s/%s", wexAPIPublicURL, wexAPIPublicVersion, wexDepth, symbol)
|
||||
|
||||
err := common.SendHTTPGetRequest(req, true, &response.Data)
|
||||
err := common.SendHTTPGetRequest(req, true, w.Verbose, &response.Data)
|
||||
if err != nil {
|
||||
return Orderbook{}, err
|
||||
}
|
||||
@@ -146,7 +146,7 @@ func (w *WEX) GetTrades(symbol string) ([]Trades, error) {
|
||||
response := Response{}
|
||||
req := fmt.Sprintf("%s/%s/%s/%s", wexAPIPublicURL, wexAPIPublicVersion, wexTrades, symbol)
|
||||
|
||||
err := common.SendHTTPGetRequest(req, true, &response.Data)
|
||||
err := common.SendHTTPGetRequest(req, true, w.Verbose, &response.Data)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
@@ -90,62 +90,17 @@ func GetEthereumBalance(address []string) (EtherchainBalanceResponse, error) {
|
||||
return result, nil
|
||||
}
|
||||
|
||||
<<<<<<< dae90a2eaa109648bdb85f8298d805e00ad4e974
|
||||
// GetCryptoIDAddress queries CryptoID for an address balance for a
|
||||
// specified cryptocurrency
|
||||
func GetCryptoIDAddress(address string, coinType string) (float64, error) {
|
||||
ok, err := common.IsValidCryptoAddress(address, coinType)
|
||||
if !ok || err != nil {
|
||||
return 0, errors.New("invalid address")
|
||||
=======
|
||||
// GetBlockrBalanceSingle queries Blockr for an address balance for either a
|
||||
// LTC or a BTC single address
|
||||
func GetBlockrBalanceSingle(address string, coinType string) (BlockrAddressBalanceSingle, error) {
|
||||
valid, _ := common.IsValidCryptoAddress(address, coinType)
|
||||
if !valid {
|
||||
return BlockrAddressBalanceSingle{}, fmt.Errorf(
|
||||
"Not a %s address", common.StringToUpper(coinType),
|
||||
)
|
||||
}
|
||||
|
||||
url := fmt.Sprintf(
|
||||
"https://%s.%s/v%s/%s/%s", common.StringToLower(coinType), blockrAPIURL,
|
||||
blockrAPIVersion, blockrAddressBalance, address,
|
||||
)
|
||||
result := BlockrAddressBalanceSingle{}
|
||||
err := common.SendHTTPGetRequest(url, true, false, &result)
|
||||
if err != nil {
|
||||
return result, err
|
||||
}
|
||||
if result.Status != "success" {
|
||||
return result, errors.New(result.Message)
|
||||
>>>>>>> In the common package added JSONDecode error check. Added verbosity in SendHTTPGetRequest. Updated Nonce package function. Fixed issues in ItBit package and expanded test coverage.
|
||||
}
|
||||
|
||||
<<<<<<< dae90a2eaa109648bdb85f8298d805e00ad4e974
|
||||
var result interface{}
|
||||
url := fmt.Sprintf("%s/%s/api.dws?q=getbalance&a=%s", cryptoIDAPIURL, common.StringToLower(coinType), address)
|
||||
err = common.SendHTTPGetRequest(url, true, &result)
|
||||
=======
|
||||
// GetBlockrAddressMulti queries Blockr for an address balance for either a LTC
|
||||
// or a BTC multiple addresses
|
||||
func GetBlockrAddressMulti(addresses []string, coinType string) (BlockrAddressBalanceMulti, error) {
|
||||
for _, add := range addresses {
|
||||
valid, _ := common.IsValidCryptoAddress(add, coinType)
|
||||
if !valid {
|
||||
return BlockrAddressBalanceMulti{}, fmt.Errorf(
|
||||
"Not a %s address", common.StringToUpper(coinType),
|
||||
)
|
||||
}
|
||||
}
|
||||
addressesStr := common.JoinStrings(addresses, ",")
|
||||
url := fmt.Sprintf(
|
||||
"https://%s.%s/v%s/%s/%s", common.StringToLower(coinType), blockrAPIURL,
|
||||
blockrAPIVersion, blockrAddressBalance, addressesStr,
|
||||
)
|
||||
result := BlockrAddressBalanceMulti{}
|
||||
err := common.SendHTTPGetRequest(url, true, false, &result)
|
||||
>>>>>>> In the common package added JSONDecode error check. Added verbosity in SendHTTPGetRequest. Updated Nonce package function. Fixed issues in ItBit package and expanded test coverage.
|
||||
err = common.SendHTTPGetRequest(url, true, false, &result)
|
||||
if err != nil {
|
||||
return 0, err
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user