zold 0.13.41 → 0.13.42

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: cfad31c18d9d2a2cd394ad6048f510f0fd641829
4
- data.tar.gz: 015adb1359b0b211176952d87bd273083a4e75e5
3
+ metadata.gz: af5c3740f905dabd3a8e7454e7b0bf65d9c3472b
4
+ data.tar.gz: 91b089acdcca61e29768a8b2a31cc8f046d71ef4
5
5
  SHA512:
6
- metadata.gz: d5f085be6e9bb8fcdda41456aa2b45b23ea0202ef31c418190b34cec2e4a09f62e7c3f84d562e3933f827e0dd4909a7185bef76bf050566c42b88b62ed24767f
7
- data.tar.gz: 122dba33d6bbc9de48af9e588873d7d5f7b00b7be6dcd9bedff4281bd3fcde478b0df38138a5785fb0e56a24783511d65762c1cbbd2f2074a59197945f249c3b
6
+ metadata.gz: 90ce9c75f3b34aa7d6eac595eea885977875721c5bc258dbdd8b8f851182ed80e7968ea4722e068670f93e97f162d8507e6dc53f758456c54cf74a7aab56bfa6
7
+ data.tar.gz: de73f91cf870c7bc3b8236e297e7e93a5f9f2e9ec37c4db7fa9b1ad56aafbc8c3e32a92a944d3f57b461916992671fb5650581ce4eed64ad1d2c34eeac939605
@@ -88,7 +88,8 @@ Available options:"
88
88
  content = AtomicFile.new(wallet.path).read
89
89
  response = r.http("/wallet/#{wallet.id}#{opts['sync'] ? '?sync=true' : ''}").put(content)
90
90
  if response.code == '304'
91
- @log.info("#{r}: same version of #{wallet.id} there, in #{(Time.now - start).round(2)}s")
91
+ @log.info("#{r}: same version #{content.length}b/#{wallet.txns.count}t \
92
+ of #{wallet.id} there, in #{(Time.now - start).round(2)}s")
92
93
  return 0
93
94
  end
94
95
  r.assert_code(200, response)
@@ -167,7 +167,22 @@ module Zold
167
167
  wallet = settings.wallets.find(id)
168
168
  error 404 unless wallet.exists?
169
169
  content_type 'text/plain'
170
- wallet.key.to_s.to_s
170
+ wallet.key.to_s
171
+ end
172
+
173
+ get %r{/wallet/(?<id>[A-Fa-f0-9]{16})\.txt} do
174
+ id = Id.new(params[:id])
175
+ wallet = settings.wallets.find(id)
176
+ error 404 unless wallet.exists?
177
+ content_type 'text/plain'
178
+ [
179
+ wallet.network,
180
+ wallet.version,
181
+ wallet.id.to_s,
182
+ wallet.key.to_s,
183
+ '',
184
+ wallet.txns.map(&:to_text).join("\n")
185
+ ].join("\n")
171
186
  end
172
187
 
173
188
  put %r{/wallet/(?<id>[A-Fa-f0-9]{16})/?} do
data/lib/zold/patch.rb CHANGED
@@ -74,8 +74,10 @@ module Zold
74
74
  @log.error("An attempt to overwrite #{dup.to_text} with this: #{txn.to_text}")
75
75
  next
76
76
  end
77
- if @txns.map(&:amount).map(&:to_i).inject(&:+).to_i < txn.amount.to_i * -1 && !wallet.root?
78
- @log.error("Transaction ##{txn.id} attempts to make the balance of #{wallet.id} negative: #{txn.to_text}")
77
+ balance = @txns.map(&:amount).map(&:to_i).inject(&:+).to_i
78
+ if balance < txn.amount.to_i * -1 && !wallet.root?
79
+ @log.error("Transaction ##{txn.id} attempts to make the balance of \
80
+ #{wallet.id}/#{Amount.new(coins: balance).to_zld}/#{@txns.size} negative: #{txn.to_text}")
79
81
  next
80
82
  end
81
83
  unless Signature.new.valid?(@key, wallet.id, txn)
data/lib/zold/version.rb CHANGED
@@ -23,5 +23,5 @@
23
23
  # Copyright:: Copyright (c) 2018 Yegor Bugayenko
24
24
  # License:: MIT
25
25
  module Zold
26
- VERSION = '0.13.41'.freeze
26
+ VERSION = '0.13.42'.freeze
27
27
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: zold
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.13.41
4
+ version: 0.13.42
5
5
  platform: ruby
6
6
  authors:
7
7
  - Yegor Bugayenko