}
resultErr := CallExternalService(fmt.Sprintf("'%s' TestCredentials", q.In.Market), EXTERNAL_SERVICE_TIMEOUT_SECONDS*time.Second, func() error {
- err := Poloniex.TestCredentials(config.Config["key"], config.Config["secret"])
+ err := Poloniex.TestCredentials(config.Config["key"], config.Config["secret"], EXTERNAL_SERVICE_TIMEOUT_SECONDS)
if utils.ErrIs(err, markets.InvalidCredentials) {
return &Error{InvalidMarketCredentials, "wrong market credentials", fmt.Errorf("wrong '%v' market credentials", q.In.Market)}
}
resultErr := CallExternalService(fmt.Sprintf("'%s' TestCredentials", q.In.Market), EXTERNAL_SERVICE_TIMEOUT_SECONDS*time.Second, func() error {
- err := Poloniex.TestCredentials(marketConfig.Config["key"], marketConfig.Config["secret"])
+ err := Poloniex.TestCredentials(marketConfig.Config["key"], marketConfig.Config["secret"], EXTERNAL_SERVICE_TIMEOUT_SECONDS)
if utils.ErrIs(err, markets.InvalidCredentials) {
return &Error{InvalidMarketCredentials, "wrong market credentials", fmt.Errorf("wrong '%v' market credentials", q.In.Market)}
IPRestricted = utils.InitFlag(&ErrorFlagCounter, "IPRestricted")
)
+const defaultTimeout = 10
+
func poloniexInvalidCredentialsError(err error) bool {
if err == nil {
return false
}
func NewPoloniex() *Poloniex {
- client, _ := poloniex.NewClient("", "")
+ client, _ := poloniex.NewClient("", "", defaultTimeout)
return &Poloniex{
TickerCache: make(map[string]CurrencyPair),
}
}
-func (p *Poloniex) TestCredentials(apiKey, apiSecret string) error {
- client, _ := poloniex.NewClient(apiKey, apiSecret)
+func (p *Poloniex) TestCredentials(apiKey, apiSecret string, timeout int32) error {
+ client, _ := poloniex.NewClient(apiKey, apiSecret, timeout)
_, err := client.TradeReturnDepositAdresses()
return err
}
-func (p *Poloniex) GetBalance(apiKey, apiSecret string) (Summary, error) {
- client, _ := poloniex.NewClient(apiKey, apiSecret)
+func (p *Poloniex) GetBalance(apiKey, apiSecret string, timeout int32) (Summary, error) {
+ client, _ := poloniex.NewClient(apiKey, apiSecret, timeout)
var summary Summary
accounts, err := client.TradeReturnAvailableAccountBalances()