mirror of
https://github.com/LBRYFoundation/pool.git
synced 2025-09-30 15:20:36 +00:00
kraken: set a timeout to api calls
This commit is contained in:
parent
87128640a3
commit
5f1779673d
2 changed files with 9 additions and 2 deletions
|
@ -57,7 +57,8 @@ class ExchangeCommand extends CConsoleCommand
|
|||
|
||||
if (!empty(EXCH_BITTREX_KEY)) {
|
||||
$balance = bittrex_api_query('account/getbalance','¤cy=BTC');
|
||||
echo("bittrex btc: ".json_encode($balance->result)."\n");
|
||||
if (!is_object($balance)) echo "bittrex error\n";
|
||||
else echo("bittrex btc: ".json_encode($balance->result)."\n");
|
||||
}
|
||||
if (!empty(EXCH_BLEUTRADE_KEY)) {
|
||||
$balance = bleutrade_api_query('account/getbalances','¤cies=BTC');
|
||||
|
@ -66,7 +67,7 @@ class ExchangeCommand extends CConsoleCommand
|
|||
if (!empty(EXCH_BTER_KEY)) {
|
||||
$info = bter_api_user('getfunds');
|
||||
if (!$info || arraySafeVal($info,'result') != 'true' || !isset($info['available_funds'])) echo "error\n";
|
||||
echo("bter available: ".json_encode($info['available_funds'])."\n");
|
||||
else echo("bter available: ".json_encode($info['available_funds'])."\n");
|
||||
}
|
||||
if (!empty(EXCH_CCEX_KEY)) {
|
||||
$ccex = new CcexAPI;
|
||||
|
|
|
@ -86,6 +86,9 @@ class KrakenAPI
|
|||
curl_setopt($this->curl, CURLOPT_URL, $this->url . '/' . $this->version . '/public/' . $method);
|
||||
curl_setopt($this->curl, CURLOPT_POSTFIELDS, $postdata);
|
||||
curl_setopt($this->curl, CURLOPT_HTTPHEADER, array());
|
||||
curl_setopt($this->curl, CURLOPT_CONNECTTIMEOUT, 10);
|
||||
curl_setopt($this->curl, CURLOPT_TIMEOUT, 20);
|
||||
|
||||
$result = curl_exec($this->curl);
|
||||
if($result===false)
|
||||
throw new KrakenAPIException('CURL error: ' . curl_error($this->curl));
|
||||
|
@ -130,6 +133,9 @@ class KrakenAPI
|
|||
curl_setopt($this->curl, CURLOPT_URL, $this->url . $path);
|
||||
curl_setopt($this->curl, CURLOPT_POSTFIELDS, $postdata);
|
||||
curl_setopt($this->curl, CURLOPT_HTTPHEADER, $headers);
|
||||
curl_setopt($this->curl, CURLOPT_CONNECTTIMEOUT, 10);
|
||||
curl_setopt($this->curl, CURLOPT_TIMEOUT, 20);
|
||||
|
||||
$result = curl_exec($this->curl);
|
||||
if($result===false)
|
||||
throw new KrakenAPIException('CURL error: ' . curl_error($this->curl));
|
||||
|
|
Loading…
Add table
Reference in a new issue