andrewroth-btce 0.1.9.2 → 0.1.9.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (2) hide show
  1. data/lib/btce.rb +8 -2
  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
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: andrewroth-btce
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.9.2
4
+ version: 0.1.9.3
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors: