andrewroth-btce 0.1.9.3 → 0.1.9.4

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 -4
  2. metadata +1 -1
data/lib/btce.rb CHANGED
@@ -283,10 +283,14 @@ module Btce
283
283
  end
284
284
 
285
285
  def nonce
286
- @nonce ||= File.exists?("btce-nonce") ? File.read("btce-nonce").to_i : 0
287
- @nonce += 1
288
- File.open("btce-nonce", "w") do |f| f.write(@nonce) end
289
- Time::now.to_i + @nonce
286
+ File.open("btce-nonce", "a+") do |f|
287
+ f.flock(File::LOCK_EX)
288
+ @nonce = f.read.to_i
289
+ @nonce += 1
290
+ f.truncate(0)
291
+ f.puts(@nonce)
292
+ end
293
+ return Time::now.to_i + @nonce
290
294
  end
291
295
  private :nonce
292
296
 
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.3
4
+ version: 0.1.9.4
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors: