aboutsummaryrefslogtreecommitdiff
path: root/markets/poloniex.go
diff options
context:
space:
mode:
authorjloup <jean-loup.jamet@trainline.com>2018-06-21 09:32:48 +0200
committerjloup <jean-loup.jamet@trainline.com>2018-06-21 09:33:10 +0200
commitc086df915bf9884fe514a00b6c6d04f36321e1e3 (patch)
tree874017c71c0c7801cf9b42192cefbe0dd316dacf /markets/poloniex.go
parentf7521f251456fea091d1eb950fd55a7cd4257c65 (diff)
downloadFront-c086df915bf9884fe514a00b6c6d04f36321e1e3.tar.gz
Front-c086df915bf9884fe514a00b6c6d04f36321e1e3.tar.zst
Front-c086df915bf9884fe514a00b6c6d04f36321e1e3.zip
Set poloniex client timeout to 20 seconds.v0.0.21
Diffstat (limited to 'markets/poloniex.go')
-rw-r--r--markets/poloniex.go12
1 files changed, 7 insertions, 5 deletions
diff --git a/markets/poloniex.go b/markets/poloniex.go
index cadc829..595d5a4 100644
--- a/markets/poloniex.go
+++ b/markets/poloniex.go
@@ -16,6 +16,8 @@ var (
16 IPRestricted = utils.InitFlag(&ErrorFlagCounter, "IPRestricted") 16 IPRestricted = utils.InitFlag(&ErrorFlagCounter, "IPRestricted")
17) 17)
18 18
19const defaultTimeout = 10
20
19func poloniexInvalidCredentialsError(err error) bool { 21func poloniexInvalidCredentialsError(err error) bool {
20 if err == nil { 22 if err == nil {
21 return false 23 return false
@@ -43,7 +45,7 @@ type Poloniex struct {
43} 45}
44 46
45func NewPoloniex() *Poloniex { 47func NewPoloniex() *Poloniex {
46 client, _ := poloniex.NewClient("", "") 48 client, _ := poloniex.NewClient("", "", defaultTimeout)
47 49
48 return &Poloniex{ 50 return &Poloniex{
49 TickerCache: make(map[string]CurrencyPair), 51 TickerCache: make(map[string]CurrencyPair),
@@ -52,8 +54,8 @@ func NewPoloniex() *Poloniex {
52 } 54 }
53} 55}
54 56
55func (p *Poloniex) TestCredentials(apiKey, apiSecret string) error { 57func (p *Poloniex) TestCredentials(apiKey, apiSecret string, timeout int32) error {
56 client, _ := poloniex.NewClient(apiKey, apiSecret) 58 client, _ := poloniex.NewClient(apiKey, apiSecret, timeout)
57 59
58 _, err := client.TradeReturnDepositAdresses() 60 _, err := client.TradeReturnDepositAdresses()
59 61
@@ -68,8 +70,8 @@ func (p *Poloniex) TestCredentials(apiKey, apiSecret string) error {
68 return err 70 return err
69} 71}
70 72
71func (p *Poloniex) GetBalance(apiKey, apiSecret string) (Summary, error) { 73func (p *Poloniex) GetBalance(apiKey, apiSecret string, timeout int32) (Summary, error) {
72 client, _ := poloniex.NewClient(apiKey, apiSecret) 74 client, _ := poloniex.NewClient(apiKey, apiSecret, timeout)
73 var summary Summary 75 var summary Summary
74 76
75 accounts, err := client.TradeReturnAvailableAccountBalances() 77 accounts, err := client.TradeReturnAvailableAccountBalances()