andrewroth-btce 0.1.9.2 → 0.1.9.3
Sign up to get free protection for your applications and to get access to all the features.
- data/lib/btce.rb +8 -2
- metadata +1 -1
data/lib/btce.rb
CHANGED
@@ -265,7 +265,7 @@ module Btce
|
|
265
265
|
OpenSSL::HMAC.hexdigest('sha512', API::KEY['secret'], data)
|
266
266
|
end
|
267
267
|
|
268
|
-
def trade_api_call(method, extra)
|
268
|
+
def trade_api_call(method, extra, retries = 4)
|
269
269
|
params = {"method" => method, "nonce" => nonce}
|
270
270
|
if ! extra.empty?
|
271
271
|
extra.each do |k,v|
|
@@ -273,7 +273,13 @@ module Btce
|
|
273
273
|
end
|
274
274
|
end
|
275
275
|
signed = sign params
|
276
|
-
get_json "https://#{API::BTCE_DOMAIN}/tapi", params, signed
|
276
|
+
response = get_json "https://#{API::BTCE_DOMAIN}/tapi", params, signed
|
277
|
+
if response.is_a?(Hash) && response["success"] == 0 && response["error"][/invalid nonce parameter/]
|
278
|
+
sleep 1
|
279
|
+
return retries > 0 ? trade_api_call(method, extra, retries - 1) : response
|
280
|
+
else
|
281
|
+
return response
|
282
|
+
end
|
277
283
|
end
|
278
284
|
|
279
285
|
def nonce
|