Fixed merge issues, fixed race condition in gemini package.

This commit is contained in:
Ryan O'Hara-Reid
2017-09-18 15:58:24 +10:00
parent 60fc00a5b3
commit a86462b338
4 changed files with 11 additions and 56 deletions

View File

@@ -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 {