zold 0.22.4 → 0.22.5

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: ad91826d6e1a3e8d2b8b55ccdbf662ed3462098ad9ac97a638ca3a315ca16bf0
4
- data.tar.gz: 139cd5314e6dd0dac0a10f20f0933e5e1d826820f4a3386eb3f7c643b49d8acc
3
+ metadata.gz: 03bad0932b6c80df634b1a0dd7149220767feb14818e8b22e310dad000630c24
4
+ data.tar.gz: eede3cc1a49152385f4ed01067343523719aaccb774e294a3f9b32987c53b155
5
5
  SHA512:
6
- metadata.gz: 3004779c370ec2ce966c89cbfa4e004c5b8644e164da6ab7a6dfb3be0eb64020853979eb6cf9ab2b8a980f0d6b0b8b610dfa44a47cdb351bd25c3d7b95341702
7
- data.tar.gz: e9901486c5cb9f653723687091a25a4902e30818757a4cd56d71c7dced8a83c5dfbefd8de77b73b5053c3e91836e6edd33dbf1169edb914e10d2e6691f35a5b5
6
+ metadata.gz: 3ff2d16edc4fa1319d41622c3362e38c2e586701670e71883e6a31cc7a4d42a1dbede754009de98b7f2386e212a6d501ca7f4a8abeb6a4d1317a61e7211ab1b8
7
+ data.tar.gz: 492ddd34efe4982713b3db909d8a260dac6ca18021474a26fd60200860e2bfb02d6d1d5d0a0a5da822728ad59b49c63a8bb950a93eb84e9bf399f6e37d623269
@@ -94,7 +94,7 @@ Available options:"
94
94
  @wallets.acq(id) do |w|
95
95
  if w.exists?
96
96
  s = Time.now
97
- merge_one(opts, patch, w, 'localhost', legacy: true)
97
+ merge_one(opts, patch, w, 'localhost', baseline: false, legacy: true)
98
98
  @log.debug("Local legacy copy of #{id} merged in #{Age.new(s)}: #{patch}")
99
99
  end
100
100
  end
@@ -102,7 +102,7 @@ Available options:"
102
102
  cps.each_with_index do |c, idx|
103
103
  wallet = Wallet.new(c[:path])
104
104
  name = "#{c[:name]}/#{idx}/#{c[:score]}"
105
- merge_one(opts, patch, wallet, name)
105
+ merge_one(opts, patch, wallet, name, baseline: !opts['no-baseline'])
106
106
  score += c[:score]
107
107
  end
108
108
  @wallets.acq(id) do |w|
@@ -125,10 +125,10 @@ into #{@wallets.acq(id, &:mnemo)} in #{Age.new(start, limit: 0.1 + cps.count * 0
125
125
  modified
126
126
  end
127
127
 
128
- def merge_one(opts, patch, wallet, name, legacy: false)
128
+ def merge_one(opts, patch, wallet, name, baseline: false, legacy: false)
129
129
  start = Time.now
130
130
  @log.debug("Building a patch for #{wallet.id} from remote copy ##{name} with #{wallet.mnemo}...")
131
- patch.join(wallet, baseline: !opts['no-baseline'], legacy: legacy) do |id|
131
+ patch.join(wallet, baseline: baseline, legacy: legacy) do |id|
132
132
  unless opts['shallow']
133
133
  Pull.new(wallets: @wallets, remotes: @remotes, copies: @copies, log: @log).run(
134
134
  ['pull', id.to_s, "--network=#{opts['network']}", '--shallow']
@@ -137,7 +137,7 @@ out of #{nodes.value} in #{Age.new(start)}, total score for #{id} is #{total.val
137
137
  r.assert_score_strength(score) unless opts['ignore-score-weakness']
138
138
  if @log.info?
139
139
  @log.info("#{r} accepted #{@wallets.acq(id, &:mnemo)} in #{Age.new(start, limit: 4)}: \
140
- #{Rainbow(score.value).green} (#{json['version']})")
140
+ #{Rainbow(score.value).green} (#{json['version']})")
141
141
  end
142
142
  score.value
143
143
  end
@@ -146,13 +146,15 @@ out of #{nodes.value} in #{Age.new(start)}, total score for #{id} is #{total.val
146
146
  def read_one(id, r, opts)
147
147
  start = Time.now
148
148
  uri = "/wallet/#{id}"
149
+ attempt = 0
149
150
  begin
150
151
  response = Tempfile.open do |f|
151
152
  @wallets.acq(id) { |w| FileUtils.copy_file(w.path, f.path) }
152
153
  r.http(uri).put(f)
153
154
  end
154
155
  if response.status == 304
155
- @log.info("#{r}: same version of #{@wallets.acq(id, &:mnemo)} there, in #{Age.new(start, limit: 0.5)}")
156
+ @log.info("#{r}: same version of #{@wallets.acq(id, &:mnemo)} there, didn't push
157
+ in #{Age.new(start, limit: 0.5)}")
156
158
  return 0
157
159
  end
158
160
  r.assert_code(200, response)
@@ -269,24 +269,7 @@ Available options:"
269
269
  r.assert_score_ownership(score)
270
270
  r.assert_score_strength(score) unless opts['ignore-score-weakness']
271
271
  @remotes.rescore(score.host, score.port, score.value)
272
- if Semantic::Version.new(VERSION) < Semantic::Version.new(json['version'])
273
- if opts['reboot']
274
- @log.info("#{r}: their version #{json['version']} is higher than mine #{VERSION}, reboot! \
275
- (use --never-reboot to avoid this from happening)")
276
- terminate
277
- end
278
- @log.debug("#{r}: their version #{json['version']} is higher than mine #{VERSION}, \
279
- it's recommended to reboot, but I don't do it because of --never-reboot")
280
- end
281
- if Semantic::Version.new(VERSION) < Semantic::Version.new(Zold::Gem.new.last_version)
282
- if opts['reboot']
283
- @log.info("#{r}: the version of the gem is higher than mine #{VERSION}, reboot! \
284
- (use --never-reboot to avoid this from happening)")
285
- terminate
286
- end
287
- @log.debug("#{r}: gem version is higher than mine #{VERSION}, \
288
- it's recommended to reboot, but I don't do it because of --never-reboot")
289
- end
272
+ reboot(r, json, opts)
290
273
  if cycle.positive?
291
274
  json['all'].each do |s|
292
275
  next if @remotes.exists?(s['host'], s['port'])
@@ -330,6 +313,30 @@ Available options:"
330
313
  end
331
314
  end
332
315
 
316
+ def reboot(r, json, opts)
317
+ return unless json['repo'] == Zold::REPO
318
+ mine = Semantic::Version.new(VERSION)
319
+ if mine < Semantic::Version.new(json['version'])
320
+ if opts['reboot']
321
+ @log.info("#{r}: their version #{json['version']} is higher than mine #{VERSION}, reboot! \
322
+ (use --never-reboot to avoid this from happening)")
323
+ terminate
324
+ end
325
+ @log.debug("#{r}: their version #{json['version']} is higher than mine #{VERSION}, \
326
+ it's recommended to reboot, but I don't do it because of --never-reboot")
327
+ end
328
+ if mine < Semantic::Version.new(Zold::Gem.new.last_version)
329
+ if opts['reboot']
330
+ @log.info("#{r}: the version of the gem is higher than mine #{VERSION}, reboot! \
331
+ (use --never-reboot to avoid this from happening)")
332
+ terminate
333
+ end
334
+ @log.debug("#{r}: gem version is higher than mine #{VERSION}, \
335
+ it's recommended to reboot, but I don't do it because of --never-reboot")
336
+ end
337
+ @log.debug("#{r}: gem version is lower or equal to mine #{VERSION}, no need to reboot")
338
+ end
339
+
333
340
  def select(opts)
334
341
  selected = @remotes.all.sort_by { |r| r[:score] }.reverse.first(opts['max-nodes'])
335
342
  (@remotes.all - selected).each do |r|
@@ -376,6 +376,7 @@ this is not a normal behavior, you may want to report a bug to our GitHub reposi
376
376
  content_type('application/json')
377
377
  pretty(
378
378
  version: settings.opts['expose-version'],
379
+ repo: Zold::REPO,
379
380
  alias: settings.node_alias,
380
381
  score: score.to_h,
381
382
  all: all_remotes,
@@ -96,7 +96,7 @@ module Zold
96
96
  def push(id, body)
97
97
  mods = @entrance.push(id, body)
98
98
  return mods if @remotes.all.empty?
99
- (mods + [id]).each do |m|
99
+ mods.each do |m|
100
100
  next if @seen.include?(m)
101
101
  @mutex.synchronize { @seen << m }
102
102
  @modified.push(m)
data/lib/zold/patch.rb CHANGED
@@ -44,6 +44,12 @@ module Zold
44
44
  "#{@txns.count} txns"
45
45
  end
46
46
 
47
+ # Joins a new wallet on top of existing patch. An attempt is made to
48
+ # copy as many transactions from the newcoming wallet to the existing
49
+ # set of transactions, avoiding mistakes and duplicates.
50
+ #
51
+ # If +baseline+ is set to TRUE the provided wallet is considered to be
52
+ # the baseline and all transactions will be blindly trusted.
47
53
  def join(wallet, baseline: true, legacy: false)
48
54
  if @id.nil?
49
55
  @id = wallet.id
data/lib/zold/version.rb CHANGED
@@ -25,7 +25,7 @@
25
25
  # Copyright:: Copyright (c) 2018 Yegor Bugayenko
26
26
  # License:: MIT
27
27
  module Zold
28
- VERSION = '0.22.4'
28
+ VERSION = '0.22.5'
29
29
  PROTOCOL = 2
30
30
  REPO = 'zold-io/zold'
31
31
  end
@@ -149,9 +149,10 @@ class TestMerge < Zold::Test
149
149
  copies = File.join(dir, 'copies')
150
150
  remotes = Zold::Remotes.new(file: File.join(dir, 'remotes'))
151
151
  Zold::Merge.new(wallets: wallets, remotes: remotes, copies: copies, log: test_log).run(
152
- %w[merge 0123456789abcdef]
152
+ %w[merge 0123456789abcdef --shallow]
153
153
  )
154
154
  Dir.chdir(dir) do
155
+ test_log.info("Testing #{f}...")
155
156
  require File.join(dir, 'assert.rb')
156
157
  end
157
158
  end
@@ -87,6 +87,7 @@ class TestRemote < Zold::Test
87
87
  body: {
88
88
  version: Zold::VERSION,
89
89
  score: zero.to_h,
90
+ repo: Zold::REPO,
90
91
  all: [
91
92
  { host: zero.host, port: zero.port }
92
93
  ]
@@ -94,7 +95,7 @@ class TestRemote < Zold::Test
94
95
  )
95
96
  stub_request(:get, 'https://rubygems.org/api/v1/versions/zold/latest.json').to_return(
96
97
  status: 200,
97
- body: '{"version": "9.9.9"}'
98
+ body: '{"version": "9.9.9", "repo": "' + Zold::REPO + '"}'
98
99
  )
99
100
  log = TestLogger.new
100
101
  cmd = Zold::Remote.new(remotes: remotes, log: log)
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.22.4
4
+ version: 0.22.5
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-01-23 00:00:00.000000000 Z
11
+ date: 2019-01-30 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: backtrace
@@ -747,7 +747,7 @@ licenses:
747
747
  - MIT
748
748
  metadata: {}
749
749
  post_install_message: |-
750
- Thanks for installing Zold 0.22.4!
750
+ Thanks for installing Zold 0.22.5!
751
751
  Study our White Paper: https://papers.zold.io/wp.pdf
752
752
  Read our blog posts: https://blog.zold.io
753
753
  Try ZLD online wallet at: https://wts.zold.io