zold 0.23.6 → 0.23.7
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/propagate.rb +2 -2
- data/lib/zold/commands/remote.rb +10 -6
- data/lib/zold/remotes.rb +20 -11
- data/lib/zold/version.rb +1 -1
- data/test/commands/test_remote.rb +23 -2
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: c510a03d5a3e6a7b5d4df8f7cf1cd90be5bb9ec44cfa8a31215f148d864edcbb
|
4
|
+
data.tar.gz: 42b34d4d44e8d25c67daa9eeb6053fba49bd9bb3bfd811b7686e76a266aefc55
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 82667cd425fec0f1fd029da8a9c418cb740da96f997a99c99a1ed02863ec995cb279636d3c62370e621ced477a3bca6f73a7407498391a4ffc6940a1dd37498b
|
7
|
+
data.tar.gz: '047049f8723e534ed026eb6a7701b66b6491aa9e7937954d4d49f4fc1788c553131bb5acc70ac68078b59baa8f6f53dffc03fe1e9efe51e1a4d8fda1d5a0ff06'
|
@@ -79,12 +79,12 @@ Available options:"
|
|
79
79
|
next
|
80
80
|
end
|
81
81
|
unless target.network == network
|
82
|
-
@log.
|
82
|
+
@log.debug("#{t.amount * -1} to #{t.bnf}: network mismatch, '#{target.network}'!='#{network}'")
|
83
83
|
next
|
84
84
|
end
|
85
85
|
next if target.includes_positive?(t.id, id)
|
86
86
|
unless target.prefix?(t.prefix)
|
87
|
-
@log.
|
87
|
+
@log.debug("#{t.amount * -1} from #{id} to #{t.bnf}: wrong prefix \"#{t.prefix}\" in \"#{t}\"")
|
88
88
|
next
|
89
89
|
end
|
90
90
|
target.add(t.inverse(id))
|
data/lib/zold/commands/remote.rb
CHANGED
@@ -260,9 +260,15 @@ Available options:"
|
|
260
260
|
|
261
261
|
def update(opts)
|
262
262
|
st = Time.now
|
263
|
+
seen = Set.new
|
263
264
|
capacity = []
|
264
|
-
opts['depth'].times do
|
265
|
+
opts['depth'].times do
|
265
266
|
@remotes.iterate(@log, farm: @farm) do |r|
|
267
|
+
if seen.include?(r.to_mnemo)
|
268
|
+
@log.debug("#{r} seen already, won't check again")
|
269
|
+
next
|
270
|
+
end
|
271
|
+
seen << r.to_mnemo
|
266
272
|
start = Time.now
|
267
273
|
update_one(r, opts) do |json, score|
|
268
274
|
r.assert_valid_score(score)
|
@@ -270,11 +276,9 @@ Available options:"
|
|
270
276
|
r.assert_score_strength(score) unless opts['ignore-score-weakness']
|
271
277
|
@remotes.rescore(score.host, score.port, score.value)
|
272
278
|
reboot(r, json, opts)
|
273
|
-
|
274
|
-
|
275
|
-
|
276
|
-
add(s['host'], s['port'], opts)
|
277
|
-
end
|
279
|
+
json['all'].each do |s|
|
280
|
+
next if @remotes.exists?(s['host'], s['port'])
|
281
|
+
add(s['host'], s['port'], opts)
|
278
282
|
end
|
279
283
|
capacity << { host: score.host, port: score.port, count: json['all'].count }
|
280
284
|
@log.info("#{r}: the score is #{Rainbow(score.value).green} (#{json['version']}) in #{Age.new(start)}")
|
data/lib/zold/remotes.rb
CHANGED
@@ -45,6 +45,8 @@ module Zold
|
|
45
45
|
# When something is wrong with the assertion
|
46
46
|
class CantAssert < StandardError; end
|
47
47
|
|
48
|
+
attr_reader :touched
|
49
|
+
|
48
50
|
def initialize(host:, port:, score:, idx:, master:, network: 'test', log: Log::NULL)
|
49
51
|
@host = host
|
50
52
|
@port = port
|
@@ -53,9 +55,11 @@ module Zold
|
|
53
55
|
@master = master
|
54
56
|
@network = network
|
55
57
|
@log = log
|
58
|
+
@touched = false
|
56
59
|
end
|
57
60
|
|
58
61
|
def http(path = '/')
|
62
|
+
@touched = true
|
59
63
|
Http.new(uri: "http://#{@host}:#{@port}#{path}", score: @score, network: @network)
|
60
64
|
end
|
61
65
|
|
@@ -67,6 +71,10 @@ module Zold
|
|
67
71
|
"#{@host}:#{@port}/#{@idx}"
|
68
72
|
end
|
69
73
|
|
74
|
+
def to_mnemo
|
75
|
+
"#{@host}:#{@port}"
|
76
|
+
end
|
77
|
+
|
70
78
|
def assert_code(code, response)
|
71
79
|
msg = response.status_line.strip
|
72
80
|
return if response.status.to_i == code
|
@@ -193,21 +201,22 @@ module Zold
|
|
193
201
|
Thread.current.name = "remotes-#{idx}@#{r[:host]}:#{r[:port]}"
|
194
202
|
start = Time.now
|
195
203
|
best = farm.best[0]
|
204
|
+
node = RemoteNode.new(
|
205
|
+
host: r[:host],
|
206
|
+
port: r[:port],
|
207
|
+
score: best.nil? ? Score::ZERO : best,
|
208
|
+
idx: idx,
|
209
|
+
master: master?(r[:host], r[:port]),
|
210
|
+
log: log,
|
211
|
+
network: @network
|
212
|
+
)
|
196
213
|
begin
|
197
|
-
yield
|
198
|
-
host: r[:host],
|
199
|
-
port: r[:port],
|
200
|
-
score: best.nil? ? Score::ZERO : best,
|
201
|
-
idx: idx,
|
202
|
-
master: master?(r[:host], r[:port]),
|
203
|
-
log: log,
|
204
|
-
network: @network
|
205
|
-
)
|
214
|
+
yield node
|
206
215
|
raise 'Took too long to execute' if (Time.now - start).round > @timeout
|
207
|
-
unerror(r[:host], r[:port])
|
216
|
+
unerror(r[:host], r[:port]) if node.touched
|
208
217
|
rescue StandardError => e
|
209
218
|
error(r[:host], r[:port])
|
210
|
-
log.info("#{Rainbow(
|
219
|
+
log.info("#{Rainbow(node).red}: #{e.message} in #{Age.new(start)}")
|
211
220
|
log.debug(Backtrace.new(e).to_s)
|
212
221
|
remove(r[:host], r[:port]) if r[:errors] > TOLERANCE
|
213
222
|
end
|
data/lib/zold/version.rb
CHANGED
@@ -74,7 +74,7 @@ class TestRemote < Zold::Test
|
|
74
74
|
cmd.run(%w[remote add localhost 2 --skip-ping])
|
75
75
|
assert_equal(2, remotes.all.count)
|
76
76
|
cmd.run(['remote', 'update', '--ignore-score-weakness', '--skip-ping'])
|
77
|
-
assert_equal(4, remotes.all.count)
|
77
|
+
assert_equal(4, remotes.all.count, remotes.all)
|
78
78
|
end
|
79
79
|
end
|
80
80
|
|
@@ -172,7 +172,7 @@ class TestRemote < Zold::Test
|
|
172
172
|
assert_equal(2, remotes.all.count)
|
173
173
|
cmd.run(['remote', 'update', '--ignore-score-weakness'])
|
174
174
|
cmd.run(['remote', 'trim', '--tolerate=0'])
|
175
|
-
assert_equal(1, remotes.all.count)
|
175
|
+
assert_equal(1, remotes.all.count, remotes.all)
|
176
176
|
end
|
177
177
|
end
|
178
178
|
|
@@ -230,4 +230,25 @@ class TestRemote < Zold::Test
|
|
230
230
|
assert(!remotes.all.empty?)
|
231
231
|
end
|
232
232
|
end
|
233
|
+
|
234
|
+
def test_updates_just_once
|
235
|
+
Dir.mktmpdir do |dir|
|
236
|
+
remotes = Zold::Remotes.new(file: File.join(dir, 'a/b/c/remotes'))
|
237
|
+
zero = Zold::Score::ZERO
|
238
|
+
get = stub_request(:get, "http://#{zero.host}:#{zero.port}/remotes").to_return(
|
239
|
+
status: 200,
|
240
|
+
headers: {},
|
241
|
+
body: {
|
242
|
+
version: Zold::VERSION,
|
243
|
+
score: zero.to_h,
|
244
|
+
all: []
|
245
|
+
}.to_json
|
246
|
+
)
|
247
|
+
cmd = Zold::Remote.new(remotes: remotes, log: test_log)
|
248
|
+
cmd.run(['remote', 'add', zero.host, zero.port.to_s, '--skip-ping'])
|
249
|
+
cmd.run(['remote', 'update', '--ignore-score-weakness', '--depth=10'])
|
250
|
+
assert_equal(1, remotes.all.count)
|
251
|
+
assert_requested(get, times: 1)
|
252
|
+
end
|
253
|
+
end
|
233
254
|
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.23.
|
4
|
+
version: 0.23.7
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Yegor Bugayenko
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2019-02-
|
11
|
+
date: 2019-02-16 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: backtrace
|
@@ -753,7 +753,7 @@ licenses:
|
|
753
753
|
- MIT
|
754
754
|
metadata: {}
|
755
755
|
post_install_message: |-
|
756
|
-
Thanks for installing Zold 0.23.
|
756
|
+
Thanks for installing Zold 0.23.7!
|
757
757
|
Study our White Paper: https://papers.zold.io/wp.pdf
|
758
758
|
Read our blog posts: https://blog.zold.io
|
759
759
|
Try ZLD online wallet at: https://wts.zold.io
|