zold 0.14.43 → 0.14.44
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/zold/age.rb +3 -1
- data/lib/zold/commands/fetch.rb +2 -2
- data/lib/zold/commands/merge.rb +8 -4
- data/lib/zold/commands/node.rb +2 -2
- data/lib/zold/commands/propagate.rb +3 -1
- data/lib/zold/commands/push.rb +4 -3
- data/lib/zold/commands/remote.rb +2 -2
- data/lib/zold/metronome.rb +6 -5
- data/lib/zold/node/async_entrance.rb +2 -1
- data/lib/zold/node/farm.rb +5 -4
- data/lib/zold/patch.rb +5 -1
- data/lib/zold/remotes.rb +3 -3
- data/lib/zold/version.rb +1 -1
- data/lib/zold/wallet.rb +1 -1
- data/test/node/test_front.rb +2 -2
- data/test/test__helper.rb +1 -1
- data/test/test_remotes.rb +2 -1
- data/test/test_wallet.rb +2 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 15f35aaff14857e15ecdb5e4c702711250f214f92eb1328e02a574ec9b8bd553
|
4
|
+
data.tar.gz: d7e082ffa042e988a17c57e41ff491070c0660a488fe5996daf8aca1d7b1aec0
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 989f7648468a8288a5429b059c4b7015c332c00f056230030ecc8b41ed1691053660bbf1714e16cd4def078e6102fb6775d5dd28c44a15e7ae3d71c7ec5f2986
|
7
|
+
data.tar.gz: 59e60d9116b5695ec7b8bc41b43f8cd1fc6621aba6dd53af2a82f139974d788bfc2e6bf22d39653c477c41ad65bef26fdcd27eea19d7959929ea4fd00b12e515
|
data/lib/zold/age.rb
CHANGED
data/lib/zold/commands/fetch.rb
CHANGED
@@ -88,7 +88,7 @@ Available options:"
|
|
88
88
|
end
|
89
89
|
raise "There are no remote nodes, run 'zold remote reset'" if nodes.value.zero?
|
90
90
|
raise "No nodes out of #{nodes.value} have the wallet #{id}" if done.value.zero? && !opts['quiet-if-absent']
|
91
|
-
@log.info("#{done.value} copies of #{id} fetched in #{(
|
91
|
+
@log.info("#{done.value} copies of #{id} fetched in #{Age.new(start)} with the total score of \
|
92
92
|
#{total.value} from #{nodes.value} nodes")
|
93
93
|
@log.debug("#{cps.all.count} local copies:")
|
94
94
|
cps.all.each do |c|
|
@@ -130,7 +130,7 @@ Available options:"
|
|
130
130
|
copy = cps.add(File.read(f), score.host, score.port, score.value)
|
131
131
|
@log.info("#{r} returned #{body.length}b/#{wallet.balance}/#{wallet.txns.count}t/\
|
132
132
|
#{digest(json)}/#{Age.new(json['mtime'])}/#{json['copies']}c \
|
133
|
-
as copy #{copy} of #{id} in #{(
|
133
|
+
as copy #{copy} of #{id} in #{Age.new(start)}: #{Rainbow(score.value).green} (#{json['version']})")
|
134
134
|
end
|
135
135
|
score.value
|
136
136
|
end
|
data/lib/zold/commands/merge.rb
CHANGED
@@ -24,6 +24,7 @@ require 'slop'
|
|
24
24
|
require 'rainbow'
|
25
25
|
require_relative 'args'
|
26
26
|
require_relative '../backtrace'
|
27
|
+
require_relative '../age'
|
27
28
|
require_relative '../log'
|
28
29
|
require_relative '../id'
|
29
30
|
require_relative '../wallet'
|
@@ -72,20 +73,22 @@ Available options:"
|
|
72
73
|
score = 0
|
73
74
|
cps.each_with_index do |c, idx|
|
74
75
|
wallet = Wallet.new(c[:path])
|
75
|
-
|
76
|
+
name = "#{c[:name]}/#{idx}/#{c[:score]}"
|
77
|
+
merge_one(opts, patch, wallet, name)
|
76
78
|
score += c[:score]
|
77
79
|
end
|
78
80
|
@wallets.find(id) do |wallet|
|
81
|
+
start = Time.now
|
79
82
|
if wallet.exists?
|
80
83
|
merge_one(opts, patch, wallet, 'localhost')
|
81
|
-
@log.debug("Local copy of #{id} merged: #{patch}")
|
84
|
+
@log.debug("Local copy of #{id} merged in #{Age.new(start)}: #{patch}")
|
82
85
|
else
|
83
86
|
@log.debug("Local copy of #{id} is absent, nothing to merge")
|
84
87
|
end
|
85
88
|
modified = patch.save(wallet.path, overwrite: true)
|
86
89
|
if modified
|
87
90
|
@log.info("#{cps.count} copies with the total score of #{score} successfully merged \
|
88
|
-
into #{wallet.id}/#{wallet.balance}/#{wallet.txns.count}t")
|
91
|
+
into #{wallet.id}/#{wallet.balance}/#{wallet.txns.count}t in #{Age.new(start)}")
|
89
92
|
else
|
90
93
|
@log.info("Nothing changed in #{wallet.id} after merge of #{cps.count} copies")
|
91
94
|
end
|
@@ -94,9 +97,10 @@ into #{wallet.id}/#{wallet.balance}/#{wallet.txns.count}t")
|
|
94
97
|
end
|
95
98
|
|
96
99
|
def merge_one(opts, patch, wallet, name)
|
100
|
+
start = Time.now
|
97
101
|
@log.debug("Building a patch for #{wallet.id} from remote copy #{name}...")
|
98
102
|
patch.join(wallet, !opts['no-baseline'])
|
99
|
-
@log.debug("Copy #{name} of #{wallet.id} merged: #{patch}")
|
103
|
+
@log.debug("Copy #{name} of #{wallet.id} merged in #{Age.new(start)}: #{patch}")
|
100
104
|
rescue StandardError => e
|
101
105
|
@log.error("Can't merge copy #{name}: #{e.message}")
|
102
106
|
@log.debug(Backtrace.new(e).to_s)
|
data/lib/zold/commands/node.rb
CHANGED
@@ -23,6 +23,7 @@
|
|
23
23
|
require 'open3'
|
24
24
|
require 'slop'
|
25
25
|
require_relative '../version'
|
26
|
+
require_relative '../age'
|
26
27
|
require_relative '../score'
|
27
28
|
require_relative '../backtrace'
|
28
29
|
require_relative '../metronome'
|
@@ -264,8 +265,7 @@ module Zold
|
|
264
265
|
end
|
265
266
|
nohup_log.print("Nothing else left to read from ##{thr.pid}\n")
|
266
267
|
code = thr.value.to_i
|
267
|
-
nohup_log.print("Exit code of process ##{thr.pid} is #{code}, was alive for \
|
268
|
-
#{((Time.now - start) / 60).round} min: #{cmd}\n")
|
268
|
+
nohup_log.print("Exit code of process ##{thr.pid} is #{code}, was alive for #{Age.new(start)}: #{cmd}\n")
|
269
269
|
code
|
270
270
|
end
|
271
271
|
end
|
@@ -24,6 +24,7 @@ require 'slop'
|
|
24
24
|
require 'rainbow'
|
25
25
|
require_relative 'args'
|
26
26
|
require_relative '../log'
|
27
|
+
require_relative '../age'
|
27
28
|
require_relative '../wallet'
|
28
29
|
require_relative '../wallets'
|
29
30
|
require_relative '../prefixes'
|
@@ -60,6 +61,7 @@ Available options:"
|
|
60
61
|
|
61
62
|
# Returns list of Wallet IDs which were affected
|
62
63
|
def propagate(id, _)
|
64
|
+
start = Time.now
|
63
65
|
modified = []
|
64
66
|
@wallets.find(id) do |wallet|
|
65
67
|
wallet.txns.select { |t| t.amount.negative? }.each do |t|
|
@@ -85,7 +87,7 @@ Available options:"
|
|
85
87
|
end
|
86
88
|
end
|
87
89
|
modified.uniq!
|
88
|
-
@log.debug("Wallet #{id} propagated successfully, #{modified.count} wallets affected")
|
90
|
+
@log.debug("Wallet #{id} propagated successfully in #{Age.new(start)}, #{modified.count} wallets affected")
|
89
91
|
modified
|
90
92
|
end
|
91
93
|
end
|
data/lib/zold/commands/push.rb
CHANGED
@@ -25,6 +25,7 @@ require 'slop'
|
|
25
25
|
require 'json'
|
26
26
|
require 'net/http'
|
27
27
|
require_relative 'args'
|
28
|
+
require_relative '../age'
|
28
29
|
require_relative '../log'
|
29
30
|
require_relative '../id'
|
30
31
|
require_relative '../http'
|
@@ -77,7 +78,7 @@ Available options:"
|
|
77
78
|
end
|
78
79
|
raise "There are no remote nodes, run 'zold remote reset'" if nodes.zero?
|
79
80
|
raise "No nodes out of #{nodes} accepted the wallet #{id}" if done.zero?
|
80
|
-
@log.info("Push finished to #{done} nodes out of #{nodes} in #{(
|
81
|
+
@log.info("Push finished to #{done} nodes out of #{nodes} in #{Age.new(start)}, \
|
81
82
|
total score for #{id} is #{total}")
|
82
83
|
end
|
83
84
|
|
@@ -96,7 +97,7 @@ total score for #{id} is #{total}")
|
|
96
97
|
@wallets.find(id) do |wallet|
|
97
98
|
if response.code == '304'
|
98
99
|
@log.info("#{r}: same version #{content.length}b/#{wallet.txns.count}t \
|
99
|
-
of #{wallet.id} there, in #{(
|
100
|
+
of #{wallet.id} there, in #{Age.new(start)}")
|
100
101
|
return 0
|
101
102
|
end
|
102
103
|
r.assert_code(200, response)
|
@@ -106,7 +107,7 @@ of #{wallet.id} there, in #{(Time.now - start).round(2)}s")
|
|
106
107
|
r.assert_score_ownership(score)
|
107
108
|
r.assert_score_strength(score) unless opts['ignore-score-weakness']
|
108
109
|
@log.info("#{r} accepted #{content.length}b/#{wallet.digest[0, 6]}/#{wallet.txns.count}t of #{wallet.id} \
|
109
|
-
in #{(
|
110
|
+
in #{Age.new(start)}: #{Rainbow(score.value).green} (#{json['version']})")
|
110
111
|
score.value
|
111
112
|
end
|
112
113
|
end
|
data/lib/zold/commands/remote.rb
CHANGED
@@ -29,6 +29,7 @@ require 'time'
|
|
29
29
|
require_relative 'args'
|
30
30
|
require_relative '../node/farm'
|
31
31
|
require_relative '../log'
|
32
|
+
require_relative '../age'
|
32
33
|
require_relative '../json_page'
|
33
34
|
require_relative '../http'
|
34
35
|
require_relative '../remotes'
|
@@ -244,8 +245,7 @@ it's recommended to reboot, but I don't do it because of --never-reboot")
|
|
244
245
|
end
|
245
246
|
end
|
246
247
|
capacity << { host: score.host, port: score.port, count: json['all'].count }
|
247
|
-
@log.info("#{r}: the score is #{Rainbow(score.value).green} (#{json['version']})
|
248
|
-
in #{(Time.now - start).round(2)}s")
|
248
|
+
@log.info("#{r}: the score is #{Rainbow(score.value).green} (#{json['version']}) in #{Age.new(start)}")
|
249
249
|
end
|
250
250
|
max_capacity = capacity.map { |c| c[:count] }.max || 0
|
251
251
|
capacity.each do |c|
|
data/lib/zold/metronome.rb
CHANGED
@@ -21,6 +21,7 @@
|
|
21
21
|
# SOFTWARE.
|
22
22
|
|
23
23
|
require_relative 'log'
|
24
|
+
require_relative 'age'
|
24
25
|
require_relative 'verbose_thread'
|
25
26
|
require_relative 'backtrace'
|
26
27
|
|
@@ -60,10 +61,10 @@ module Zold
|
|
60
61
|
start = Time.now
|
61
62
|
begin
|
62
63
|
r.exec(step)
|
63
|
-
@log.info("Routine #{r.class.name} ##{step} done in #{(
|
64
|
+
@log.info("Routine #{r.class.name} ##{step} done in #{Age.new(start)}")
|
64
65
|
rescue StandardError => e
|
65
66
|
@failures[r.class.name] = Backtrace.new(e).to_s
|
66
|
-
@log.error("Routine #{r.class.name} ##{step} failed in #{(
|
67
|
+
@log.error("Routine #{r.class.name} ##{step} failed in #{Age.new(start)}")
|
67
68
|
@log.error(Backtrace.new(e).to_s)
|
68
69
|
end
|
69
70
|
step += 1
|
@@ -80,13 +81,13 @@ module Zold
|
|
80
81
|
@threads.each do |t|
|
81
82
|
tstart = Time.now
|
82
83
|
if t.join(60)
|
83
|
-
@log.info("Thread #{t.name} finished in #{(
|
84
|
+
@log.info("Thread #{t.name} finished in #{Age.new(tstart)}")
|
84
85
|
else
|
85
86
|
t.exit
|
86
|
-
@log.info("Thread #{t.name} killed in #{(
|
87
|
+
@log.info("Thread #{t.name} killed in #{Age.new(tstart)}")
|
87
88
|
end
|
88
89
|
end
|
89
|
-
@log.info("Metronome stopped in #{(
|
90
|
+
@log.info("Metronome stopped in #{Age.new(start)}, #{@failures.count} failures")
|
90
91
|
end
|
91
92
|
end
|
92
93
|
end
|
@@ -22,6 +22,7 @@
|
|
22
22
|
|
23
23
|
require 'concurrent'
|
24
24
|
require_relative '../log'
|
25
|
+
require_relative '../age'
|
25
26
|
require_relative '../id'
|
26
27
|
require_relative '../verbose_thread'
|
27
28
|
|
@@ -117,7 +118,7 @@ module Zold
|
|
117
118
|
return if id.empty? || body.empty?
|
118
119
|
start = Time.now
|
119
120
|
@entrance.push(Id.new(id), body)
|
120
|
-
@log.debug("Pushed #{id}/#{body.length}b to #{@entrance.class.name} in #{(
|
121
|
+
@log.debug("Pushed #{id}/#{body.length}b to #{@entrance.class.name} in #{Age.new(start)}")
|
121
122
|
end
|
122
123
|
|
123
124
|
def queue
|
data/lib/zold/node/farm.rb
CHANGED
@@ -24,6 +24,7 @@ require 'time'
|
|
24
24
|
require 'open3'
|
25
25
|
require_relative '../log'
|
26
26
|
require_relative '../score'
|
27
|
+
require_relative '../age'
|
27
28
|
require_relative '../verbose_thread'
|
28
29
|
require_relative '../backtrace'
|
29
30
|
require_relative '../atomic_file'
|
@@ -118,7 +119,7 @@ module Zold
|
|
118
119
|
start = Time.now
|
119
120
|
finish(@cleanup)
|
120
121
|
@threads.each { |t| finish(t) }
|
121
|
-
@log.info("Farm stopped in #{(
|
122
|
+
@log.info("Farm stopped in #{Age.new(start)}")
|
122
123
|
end
|
123
124
|
end
|
124
125
|
|
@@ -129,14 +130,14 @@ module Zold
|
|
129
130
|
@alive = false
|
130
131
|
@log.info("Attempting to terminate the thread \"#{thread.name}\"...")
|
131
132
|
loop do
|
132
|
-
delay =
|
133
|
+
delay = Time.now - start
|
133
134
|
if thread.join(0.1)
|
134
|
-
@log.info("Thread \"#{thread.name}\" finished in #{
|
135
|
+
@log.info("Thread \"#{thread.name}\" finished in #{Age.new(start)}")
|
135
136
|
break
|
136
137
|
end
|
137
138
|
if delay > 10
|
138
139
|
thread.exit
|
139
|
-
@log.error("Thread \"#{thread.name}\" forcefully terminated after #{
|
140
|
+
@log.error("Thread \"#{thread.name}\" forcefully terminated after #{Age.new(start)}")
|
140
141
|
end
|
141
142
|
end
|
142
143
|
end
|
data/lib/zold/patch.rb
CHANGED
@@ -123,7 +123,11 @@ among #{payer.txns.count} transactions: #{txn.to_text}")
|
|
123
123
|
before = AtomicFile.new(file).read if File.exist?(file)
|
124
124
|
wallet = Wallet.new(file)
|
125
125
|
wallet.init(@id, @key, overwrite: overwrite, network: @network)
|
126
|
-
|
126
|
+
File.open(file, 'a') do |f|
|
127
|
+
@txns.each do |txn|
|
128
|
+
f.print "#{txn}\n"
|
129
|
+
end
|
130
|
+
end
|
127
131
|
wallet.refurbish
|
128
132
|
after = AtomicFile.new(file).read
|
129
133
|
before != after
|
data/lib/zold/remotes.rb
CHANGED
@@ -27,6 +27,7 @@ require 'net/http'
|
|
27
27
|
require 'time'
|
28
28
|
require 'fileutils'
|
29
29
|
require_relative 'backtrace'
|
30
|
+
require_relative 'age'
|
30
31
|
require_relative 'score'
|
31
32
|
require_relative 'http'
|
32
33
|
require_relative 'node/farm'
|
@@ -100,7 +101,7 @@ module Zold
|
|
100
101
|
|
101
102
|
def assert_valid_score(score)
|
102
103
|
raise "Invalid score #{score}" unless score.valid?
|
103
|
-
raise "Expired score #{score}" if score.expired?
|
104
|
+
raise "Expired score (#{Age.new(score.time)}) #{score}" if score.expired?
|
104
105
|
end
|
105
106
|
|
106
107
|
def assert_score_ownership(score)
|
@@ -197,8 +198,7 @@ module Zold
|
|
197
198
|
raise 'Took too long to execute' if (Time.now - start).round > timeout
|
198
199
|
rescue StandardError => e
|
199
200
|
error(r[:host], r[:port])
|
200
|
-
log.info("#{Rainbow("#{r[:host]}:#{r[:port]}").red}: #{e.message}
|
201
|
-
in #{(Time.now - start).round}s")
|
201
|
+
log.info("#{Rainbow("#{r[:host]}:#{r[:port]}").red}: #{e.message} in #{Age.new(start)}")
|
202
202
|
log.debug(Backtrace.new(e).to_s)
|
203
203
|
remove(r[:host], r[:port]) if errors > Remotes::TOLERANCE
|
204
204
|
end
|
data/lib/zold/version.rb
CHANGED
data/lib/zold/wallet.rb
CHANGED
@@ -54,7 +54,7 @@ module Zold
|
|
54
54
|
EXTENSION = '.z'
|
55
55
|
|
56
56
|
def initialize(file)
|
57
|
-
@file = File.extname(file).empty? ? "#{file}#{EXTENSION}" : file
|
57
|
+
@file = File.absolute_path(File.extname(file).empty? ? "#{file}#{EXTENSION}" : file)
|
58
58
|
@txns = Txns::Cached.new(Txns.new(@file))
|
59
59
|
@head = Head::Cached.new(Head.new(@file))
|
60
60
|
end
|
data/test/node/test_front.rb
CHANGED
@@ -28,6 +28,7 @@ require_relative '../test__helper'
|
|
28
28
|
require_relative 'fake_node'
|
29
29
|
require_relative '../fake_home'
|
30
30
|
require_relative '../../lib/zold/http'
|
31
|
+
require_relative '../../lib/zold/age'
|
31
32
|
require_relative '../../lib/zold/json_page'
|
32
33
|
require_relative '../../lib/zold/score'
|
33
34
|
|
@@ -209,8 +210,7 @@ class FrontTest < Minitest::Test
|
|
209
210
|
Zold::Http.new(uri: URI("http://localhost:#{port}/"), score: nil).get
|
210
211
|
end
|
211
212
|
end
|
212
|
-
|
213
|
-
test_log.info("Average response time is #{sec.round(2)}s")
|
213
|
+
test_log.info("Average response time is #{Zold::Age.new(start)}")
|
214
214
|
end
|
215
215
|
|
216
216
|
def app
|
data/test/test__helper.rb
CHANGED
@@ -53,7 +53,7 @@ module Minitest
|
|
53
53
|
end
|
54
54
|
sleep 1
|
55
55
|
sec = Time.now - start
|
56
|
-
raise "'#{actual}' is not equal to '#{expected}' even after #{
|
56
|
+
raise "'#{actual}' is not equal to '#{expected}' even after #{Age.new(start)} of waiting" if sec > max
|
57
57
|
end
|
58
58
|
end
|
59
59
|
|
data/test/test_remotes.rb
CHANGED
@@ -25,6 +25,7 @@ require 'tmpdir'
|
|
25
25
|
require 'webmock/minitest'
|
26
26
|
require_relative 'test__helper'
|
27
27
|
require_relative '../lib/zold/log'
|
28
|
+
require_relative '../lib/zold/age'
|
28
29
|
require_relative '../lib/zold/remotes'
|
29
30
|
require_relative '../lib/zold/verbose_thread'
|
30
31
|
|
@@ -218,7 +219,7 @@ class TestRemotes < Minitest::Test
|
|
218
219
|
remotes.iterate(test_log) { remotes.all }
|
219
220
|
remotes.remove('127.0.0.1', 8080 + t)
|
220
221
|
end
|
221
|
-
test_log.info("Total time: #{
|
222
|
+
test_log.info("Total time: #{Zold::Age.new(start)}")
|
222
223
|
end
|
223
224
|
end
|
224
225
|
|
data/test/test_wallet.rb
CHANGED
@@ -23,6 +23,7 @@
|
|
23
23
|
require 'minitest/autorun'
|
24
24
|
require_relative 'fake_home'
|
25
25
|
require_relative '../lib/zold/key'
|
26
|
+
require_relative '../lib/zold/age'
|
26
27
|
require_relative '../lib/zold/id'
|
27
28
|
require_relative '../lib/zold/wallet'
|
28
29
|
require_relative '../lib/zold/txn'
|
@@ -51,7 +52,7 @@ class TestWallet < Minitest::Test
|
|
51
52
|
wallet.txns
|
52
53
|
wallet.sub(Zold::Amount.new(zld: 39.99), "NOPREFIX@#{Zold::Id.new}", key)
|
53
54
|
time = Time.now - start
|
54
|
-
assert(time < 0.5, "Too slow: #{
|
55
|
+
assert(time < 0.5, "Too slow: #{Zold::Age.new(start)} seconds")
|
55
56
|
end
|
56
57
|
end
|
57
58
|
|
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.44
|
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-10-
|
11
|
+
date: 2018-10-11 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: cachy
|