zold 0.14.31 → 0.14.32

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: '069e29f108987ab9bdc7277b07493fd5b19ca10d'
4
- data.tar.gz: f4bc525e8f801da0f81bc17042e2abadd022d65c
3
+ metadata.gz: 54bf03ddc21a3ddafab0d79706aafad724b0dd46
4
+ data.tar.gz: 9640b4e47c225b2599dc79f1ac5e092727d62f9e
5
5
  SHA512:
6
- metadata.gz: 4ab173be9d3c0fc4d5f3b72dd2ec56299347d00aeef9f66de8655fe3497a59485ec425500fd09c8f68892158056f4e7c5337db1125f9c6d51f55ad24be815f98
7
- data.tar.gz: 74c9a5e05eb355731c486f1a84d7537f058f75cfe4d31eceedf6b9dc3748528ded19b8e013f7a2a3272c850d4e546dc3bd215a0434b79d05500d3a0aa023b07e
6
+ metadata.gz: 5030e872a156facb47d8a45bdfff89259833393e63dfd8699adaf51de1631faede8201f985458836b4e87654322402d867ac7f572fccef0b1e05de64495ff071
7
+ data.tar.gz: 48fe9c98343576e43dc10ded3f54748f7afb671e8ac1496d29e061842c74ebddb31810b6391c689c7fe6239f2afae9f24547455ce52d9497f80d4c731133bf51
@@ -69,6 +69,7 @@ Available options:"
69
69
  total = 0
70
70
  nodes = 0
71
71
  done = 0
72
+ start = Time.now
72
73
  @remotes.iterate(@log) do |r|
73
74
  nodes += 1
74
75
  total += push_one(id, r, opts)
@@ -76,7 +77,8 @@ Available options:"
76
77
  end
77
78
  raise "There are no remote nodes, run 'zold remote reset'" if nodes.zero?
78
79
  raise "No nodes out of #{nodes} accepted the wallet #{id}" if done.zero?
79
- @log.info("Push finished to #{done} nodes out of #{nodes}, total score for #{id} is #{total}")
80
+ @log.info("Push finished to #{done} nodes out of #{nodes} in #{(Time.now - start).round}s, \
81
+ total score for #{id} is #{total}")
80
82
  end
81
83
 
82
84
  def push_one(id, r, opts)
@@ -85,10 +87,12 @@ Available options:"
85
87
  return 0
86
88
  end
87
89
  start = Time.now
88
- @wallets.find(id) do |wallet|
90
+ content = @wallets.find(id) do |wallet|
89
91
  raise "The wallet #{id} is absent" unless wallet.exists?
90
- content = AtomicFile.new(wallet.path).read
91
- response = r.http("/wallet/#{wallet.id}#{opts['sync'] ? '?sync=true' : ''}").put(content)
92
+ AtomicFile.new(wallet.path).read
93
+ end
94
+ response = r.http("/wallet/#{id}#{opts['sync'] ? '?sync=true' : ''}").put(content)
95
+ @wallets.find(id) do |wallet|
92
96
  if response.code == '304'
93
97
  @log.info("#{r}: same version #{content.length}b/#{wallet.txns.count}t \
94
98
  of #{wallet.id} there, in #{(Time.now - start).round(2)}s")
@@ -103,8 +103,6 @@ while #{settings.address} is in '#{settings.network}'"
103
103
  require_relative '../commands/remote'
104
104
  cmd = Remote.new(remotes: settings.remotes, log: settings.log)
105
105
  cmd.run(['remote', 'add', s.host, s.port.to_s, "--network=#{settings.network}"])
106
- cmd.run(%w[remote trim])
107
- cmd.run(%w[remote select])
108
106
  end
109
107
  end
110
108
 
@@ -296,12 +294,14 @@ while #{settings.address} is in '#{settings.network}'"
296
294
  error 404 unless wallet.exists?
297
295
  content_type 'text/plain'
298
296
  copies = Copies.new(File.join(settings.copies, id))
299
- copies.load.map { |c| "#{c[:name]}: #{c[:host]}:#{c[:port]} #{c[:score]} #{c[:time]}" }.join("\n") +
297
+ copies.load.map do |c|
298
+ "#{c[:name]}: #{c[:host]}:#{c[:port]} #{c[:score]} #{c[:time].utc.iso8601}"
299
+ end.join("\n") +
300
300
  "\n\n" +
301
301
  copies.all.map do |c|
302
302
  w = Wallet.new(c[:path])
303
303
  "#{c[:name]}: #{c[:score]} #{w.balance}/#{w.txns.count}t/\
304
- #{w.digest[0, 6]}/#{File.size(c[:path])}b/#{Age.new(File.mtime(c[:path]))}"
304
+ #{w.digest[0, 6]}/#{File.size(c[:path])}b/#{Age.new(File.mtime(c[:path]))}"
305
305
  end.join("\n")
306
306
  end
307
307
  end
@@ -369,6 +369,7 @@ while #{settings.address} is in '#{settings.network}'"
369
369
  status 503
370
370
  e = env['sinatra.error']
371
371
  content_type 'text/plain'
372
+ headers['X-Zold-Error'] = e.message
372
373
  Backtrace.new(e).to_s
373
374
  end
374
375
 
data/lib/zold/remotes.rb CHANGED
@@ -82,6 +82,7 @@ module Zold
82
82
  return if response.code.to_i == code
83
83
  log.debug("#{response.code} \"#{response.message}\" at \"#{response.body}\"")
84
84
  raise "Unexpected HTTP code #{response.code}, instead of #{code}" if msg.empty?
85
+ raise "#{response.code}/#{response.header['X-Zold-Error']}" if response.header['X-Zold-Error']
85
86
  raise "#{msg} (HTTP code #{response.code}, instead of #{code})"
86
87
  end
87
88
 
data/lib/zold/version.rb CHANGED
@@ -25,6 +25,6 @@
25
25
  # Copyright:: Copyright (c) 2018 Yegor Bugayenko
26
26
  # License:: MIT
27
27
  module Zold
28
- VERSION = '0.14.31'
28
+ VERSION = '0.14.32'
29
29
  PROTOCOL = 2
30
30
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: zold
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.14.31
4
+ version: 0.14.32
5
5
  platform: ruby
6
6
  authors:
7
7
  - Yegor Bugayenko
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2018-08-10 00:00:00.000000000 Z
11
+ date: 2018-08-11 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: concurrent-ruby