zold 0.29.20 → 0.29.21

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: 3a384987626036b4943acf7207bc6043b587d5de3c69468d1c17eb2f337cbae0
4
- data.tar.gz: ad950bb71ec0e09858a0d10c6ba5baecc390648336cd766f12b79ae33388429c
3
+ metadata.gz: 1b0d7ac8dd66157373eb07294a099889a0bc0473f641f50d162179889e525fcb
4
+ data.tar.gz: 9cb56fc29fccb99b770ad25c9b1a4ffcaaf590c5534482d5e5b558cd73db7f8b
5
5
  SHA512:
6
- metadata.gz: ca5b3e919cb7442d6944fe6d0b74f212cf8ac52a7762d8f1017fd812c5f535483cd5ca24fee592fa0a1d5b955bb801929b8da7698d7c2704487dec4d9ad99f85
7
- data.tar.gz: d7b498c210aef31fe97b9216def70a89b7a0f39c5bc425ab2134f912fb8b56f3e3011446b1538cb89e85509a32ea85780616a4a2b88ebc5e1bb2dd71c86ce32b
6
+ metadata.gz: af0e8a298e25443b4d8583f3aff9c2df2da048d2d7842f7d3b5d665dbcee71131d1e42927c4d7b5f03a54097bc9d31fdbd05ccbe30eac08f92a223c1986dcc9e
7
+ data.tar.gz: 5067cdd096e87664e678cbe3bc9f152e1d835a6a9498d78b55d86ad59f004f9e051ed3218e007634fdd397d9c2318032d949c46e5940354c8107863e05be6be8
@@ -162,13 +162,13 @@ run 'zold remote update' or use --tolerate-quorum=1"
162
162
  wallet = Wallet.new(f.path)
163
163
  wallet.refurbish
164
164
  if wallet.protocol != Zold::PROTOCOL
165
- raise "Protocol #{wallet.protocol} doesn't match #{Zold::PROTOCOL} in #{id}"
165
+ raise FetchError, "Protocol #{wallet.protocol} doesn't match #{Zold::PROTOCOL} in #{id}"
166
166
  end
167
167
  if wallet.network != opts['network']
168
- raise "The wallet #{id} is in network '#{wallet.network}', while we are in '#{opts['network']}'"
168
+ raise FetchError, "The wallet #{id} is in '#{wallet.network}', while we are in '#{opts['network']}'"
169
169
  end
170
170
  if wallet.balance.negative? && !wallet.root?
171
- raise "The balance of #{id} is #{wallet.balance} and it's not a root wallet"
171
+ raise FetchError, "The balance of #{id} is #{wallet.balance} and it's not a root wallet"
172
172
  end
173
173
  copy = cps.add(IO.read(f), score.host, score.port, score.value, master: r.master?)
174
174
  @log.debug("#{r} returned #{wallet.mnemo} #{Age.new(json['mtime'])}/#{json['copies']}c \
@@ -159,8 +159,13 @@ into #{@wallets.acq(id, &:mnemo)} in #{Age.new(start, limit: 0.1 + cps.count * 0
159
159
  else
160
160
  patch.join(wallet, ledger: opts['ledger']) do |txn|
161
161
  trusted = IO.read(opts['trusted']).split(',')
162
- IO.write(opts['trusted'], (trusted + [txn.bnf.to_s]).join(','))
163
- unless trusted.include?(txn.bnf.to_s) || trusted.count > opts['trusted-max']
162
+ if trusted.include?(txn.bnf.to_s)
163
+ @log.debug("Won't PULL #{txn.bnf} since it is already trusted, among #{trusted.count} others")
164
+ elsif trusted.count > opts['trusted-max']
165
+ @log.debug("Won't PULL #{txn.bnf} since there are too many trusted wallets already: \
166
+ #{trusted.count} > #{opts['trusted-max']}")
167
+ else
168
+ IO.write(opts['trusted'], (trusted + [txn.bnf.to_s]).sort.uniq.join(','))
164
169
  Pull.new(wallets: @wallets, remotes: @remotes, copies: @copies, log: @log).run(
165
170
  ['pull', txn.bnf.to_s, "--network=#{Shellwords.escape(opts['network'])}", '--quiet-if-absent'] +
166
171
  (opts['deep'] ? ['--deep'] : ['--shallow']) +
@@ -141,7 +141,6 @@ the difference is #{(amount - from.balance).to_i} zents"
141
141
  end
142
142
  pem = IO.read(opts['private-key'])
143
143
  unless opts['keygap'].empty?
144
- puts opts['keygap']
145
144
  pem = pem.sub('*' * opts['keygap'].length, opts['keygap'])
146
145
  @log.debug("Keygap \"#{'*' * opts['keygap'].length}\" injected into the RSA private key")
147
146
  end
data/lib/zold/copies.rb CHANGED
@@ -57,7 +57,14 @@ module Zold
57
57
  def clean(max: 24 * 60 * 60)
58
58
  Futex.new(file, log: @log).open do
59
59
  list = load
60
- list.reject! { |s| s[:time] < Time.now - max }
60
+ list.reject! do |s|
61
+ if s[:time] >= Time.now - max
62
+ false
63
+ else
64
+ @log.debug("Copy ##{s[:name]}/#{s[:host]}:#{s[:port]} is too old, over #{Age.new(s[:time])}")
65
+ true
66
+ end
67
+ end
61
68
  save(list)
62
69
  deleted = 0
63
70
  files.each do |f|
@@ -68,18 +75,21 @@ module Zold
68
75
  @log.debug("Copy at #{f} deleted: #{Size.new(size)}")
69
76
  deleted += 1
70
77
  end
71
- files.each do |f|
72
- cp = File.join(@dir, f)
78
+ list.select! do |s|
79
+ cp = File.join(@dir, "#{s[:name]}#{Copies::EXT}")
73
80
  wallet = Wallet.new(cp)
74
81
  begin
75
82
  wallet.refurbish
76
83
  raise "Invalid protocol #{wallet.protocol} in #{cp}" unless wallet.protocol == Zold::PROTOCOL
84
+ true
77
85
  rescue StandardError => e
78
86
  FileUtils.rm_rf(cp)
79
- @log.debug("Copy at #{f} deleted: #{Backtrace.new(e)}")
87
+ @log.debug("Copy at #{cp} deleted: #{Backtrace.new(e)}")
80
88
  deleted += 1
89
+ false
81
90
  end
82
91
  end
92
+ save(list)
83
93
  deleted
84
94
  end
85
95
  end
@@ -98,7 +98,10 @@ module Zold
98
98
  @start = Time.now
99
99
  if !settings.opts['halt-code'].empty? && params[:halt] && params[:halt] == settings.opts['halt-code']
100
100
  settings.log.info('Halt signal received, shutting the front end down...')
101
- Front.stop!
101
+ Thread.start do
102
+ sleep 0.1
103
+ Front.stop!
104
+ end
102
105
  end
103
106
  check_header(Http::NETWORK_HEADER) do |header|
104
107
  if header != settings.opts['network']
@@ -471,7 +474,7 @@ this is not a normal behavior, you may want to report a bug to our GitHub reposi
471
474
  description: 'The journal',
472
475
  id: params[:id],
473
476
  files: DirItems.new(settings.journal_dir).fetch.sort.reverse.select do |f|
474
- !params[:id] || f.start_with?(params[:id])
477
+ !params[:id] || f.include?(params[:id])
475
478
  end,
476
479
  dir: settings.journal_dir
477
480
  }
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.29.20'
28
+ VERSION = '0.29.21'
29
29
  PROTOCOL = 2
30
30
  REPO = 'zold-io/zold'
31
31
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: zold
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.29.20
4
+ version: 0.29.21
5
5
  platform: ruby
6
6
  authors:
7
7
  - Yegor Bugayenko
@@ -798,7 +798,7 @@ licenses:
798
798
  - MIT
799
799
  metadata: {}
800
800
  post_install_message: |-
801
- Thanks for installing Zold 0.29.20!
801
+ Thanks for installing Zold 0.29.21!
802
802
  Study our White Paper: https://papers.zold.io/wp.pdf
803
803
  Read our blog posts: https://blog.zold.io
804
804
  Try ZLD online wallet at: https://wts.zold.io