zold 0.14.31 → 0.14.32
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.
- checksums.yaml +4 -4
- data/lib/zold/commands/push.rb +8 -4
- data/lib/zold/node/front.rb +5 -4
- data/lib/zold/remotes.rb +1 -0
- data/lib/zold/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 54bf03ddc21a3ddafab0d79706aafad724b0dd46
|
4
|
+
data.tar.gz: 9640b4e47c225b2599dc79f1ac5e092727d62f9e
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 5030e872a156facb47d8a45bdfff89259833393e63dfd8699adaf51de1631faede8201f985458836b4e87654322402d867ac7f572fccef0b1e05de64495ff071
|
7
|
+
data.tar.gz: 48fe9c98343576e43dc10ded3f54748f7afb671e8ac1496d29e061842c74ebddb31810b6391c689c7fe6239f2afae9f24547455ce52d9497f80d4c731133bf51
|
data/lib/zold/commands/push.rb
CHANGED
@@ -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}
|
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
|
-
|
91
|
-
|
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")
|
data/lib/zold/node/front.rb
CHANGED
@@ -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
|
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
|
-
|
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
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.
|
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-
|
11
|
+
date: 2018-08-11 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: concurrent-ruby
|