]> git.immae.eu Git - perso/Immae/Projets/Cryptomonnaies/Cryptoportfolio/Front.git/blobdiff - markets/poloniex.go
Set poloniex client timeout to 20 seconds.
[perso/Immae/Projets/Cryptomonnaies/Cryptoportfolio/Front.git] / markets / poloniex.go
index cadc8295c2464c6dedbab9306671eeea4ae7a031..595d5a4890ac73001f37c2a20f9cf4ba5abe18eb 100644 (file)
@@ -16,6 +16,8 @@ var (
        IPRestricted                          = utils.InitFlag(&ErrorFlagCounter, "IPRestricted")
 )
 
+const defaultTimeout = 10
+
 func poloniexInvalidCredentialsError(err error) bool {
        if err == nil {
                return false
@@ -43,7 +45,7 @@ type Poloniex struct {
 }
 
 func NewPoloniex() *Poloniex {
-       client, _ := poloniex.NewClient("", "")
+       client, _ := poloniex.NewClient("", "", defaultTimeout)
 
        return &Poloniex{
                TickerCache:      make(map[string]CurrencyPair),
@@ -52,8 +54,8 @@ func NewPoloniex() *Poloniex {
        }
 }
 
-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()
 
@@ -68,8 +70,8 @@ func (p *Poloniex) TestCredentials(apiKey, apiSecret string) error {
        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()