zold 0.29.23 → 0.29.24

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: 889105e0d182da51bc1e5f1404ac8a89e761ccbe3a01c2d8927093d5cbbea4b7
4
- data.tar.gz: da4dc45dd27825ea6f36d361f9d8e0617bac70f3d8d333a1471b477987498b75
3
+ metadata.gz: d9d73aef08fbd3c164e8e65f6724f5a4e1c4c0fe2c821e9638df11326d943f5d
4
+ data.tar.gz: c6a1876c19f6905231e9758433b7743889302ae7527d20134165f6ece45dbd5f
5
5
  SHA512:
6
- metadata.gz: 4378c9164cde07bc3d52df96df215632ef29c871c95cb9e6838550bd4e6b72761d3f3a8e7a73cce3e4f7825b38eb4f2d939d9ffbf49cd05edc15514c8ad32ff0
7
- data.tar.gz: 39a8d2951f30122c8abe0da442800c1bac410cc0daeafc8000ac1b7ee5dedbfa179301778c2d44692fefcc50f69effd4b6aa7a42ef64e72d3771070d5994c43d
6
+ metadata.gz: b02b08e81d5b55735f05d3358451b820d5271c45ff0bbb83242b3ebd4a52e65f5ee9f2f05f9473e06ddf0503e89a467f9a5ec9712450a2ced8c4e9330081ef6e
7
+ data.tar.gz: 2fed2a3e01d2554774d96e54bd1a240f439541bec8e58fe19fa5cb5a254f91a5f09b39026c1a088e5fa92b06f89e82e057c37cd65decf1efb4c5981301098a2d
@@ -1,3 +1,3 @@
1
1
  --verbose
2
- --deep
2
+ --depth=2
3
3
  --no-baseline
@@ -1,3 +1,3 @@
1
1
  --verbose
2
- --deep
2
+ --depth=2
3
3
  --no-baseline
@@ -74,7 +74,7 @@ Available options:"
74
74
  list = cps.all.map do |c|
75
75
  wallet = Wallet.new(c[:path])
76
76
  "#{c[:name]}: #{c[:score]} #{wallet.mnemo} \
77
- #{Size.new(File.size(c[:path]))}/#{Age.new(File.mtime(c[:path]))}"
77
+ #{Size.new(File.size(c[:path]))}/#{Age.new(File.mtime(c[:path]))}#{c[:master] ? ' master' : ''}"
78
78
  end
79
79
  @log.debug(
80
80
  "#{deleted} expired local copies removed for #{cps} \
@@ -141,7 +141,7 @@ run 'zold remote update' or use --tolerate-quorum=1"
141
141
  #{total.value} from #{nodes.value} nodes (#{masters.value} master nodes)")
142
142
  list = cps.all.map do |c|
143
143
  " ##{c[:name]}: #{c[:score]} #{Wallet.new(c[:path]).mnemo} \
144
- #{Size.new(File.size(c[:path]))}/#{Age.new(File.mtime(c[:path]))}"
144
+ #{Size.new(File.size(c[:path]))}/#{Age.new(File.mtime(c[:path]))}#{c[:master] ? ' master' : ''}"
145
145
  end
146
146
  @log.debug("#{cps.all.count} local copies of #{id}:\n#{list.join("\n")}")
147
147
  end
@@ -63,9 +63,9 @@ Available options:"
63
63
  o.bool '--quiet-if-absent',
64
64
  'Don\'t fail if the wallet is absent',
65
65
  default: false
66
- o.bool '--deep',
67
- 'Try to pull other wallets if their confirmations are required, as deep as possible',
68
- default: false
66
+ o.integer '--depth',
67
+ 'How many levels down we try to pull other wallets if their confirmations are required (default: 0)',
68
+ default: 1
69
69
  o.bool '--allow-negative-balance',
70
70
  'Don\'t check for the negative balance of the wallet after the merge',
71
71
  default: false
@@ -119,8 +119,9 @@ Available options:"
119
119
  end
120
120
  cps.each_with_index do |c, idx|
121
121
  wallet = Wallet.new(c[:path])
122
- name = "#{c[:name]}/#{idx}/#{c[:score]}"
123
- merge_one(opts, patch, wallet, name, baseline: idx.zero? && c[:master] && !opts['no-baseline'])
122
+ baseline = idx.zero? && c[:master] && !opts['no-baseline']
123
+ name = "#{c[:name]}/#{idx}/#{c[:score]}#{baseline ? '/baseline' : ''}"
124
+ merge_one(opts, patch, wallet, name, baseline: baseline)
124
125
  score += c[:score]
125
126
  end
126
127
  @wallets.acq(id) do |w|
@@ -151,7 +152,7 @@ into #{@wallets.acq(id, &:mnemo)} in #{Age.new(start, limit: 0.1 + cps.count * 0
151
152
  def merge_one(opts, patch, wallet, name, baseline: false)
152
153
  start = Time.now
153
154
  @log.debug("Building a patch for #{wallet.id} from remote copy ##{name} with #{wallet.mnemo}...")
154
- if opts['deep']
155
+ if opts['depth'].positive?
155
156
  patch.join(wallet, ledger: opts['ledger'], baseline: baseline) do |txn|
156
157
  trusted = IO.read(opts['trusted']).split(',')
157
158
  if trusted.include?(txn.bnf.to_s)
@@ -163,7 +164,7 @@ into #{@wallets.acq(id, &:mnemo)} in #{Age.new(start, limit: 0.1 + cps.count * 0
163
164
  IO.write(opts['trusted'], (trusted + [txn.bnf.to_s]).sort.uniq.join(','))
164
165
  Pull.new(wallets: @wallets, remotes: @remotes, copies: @copies, log: @log).run(
165
166
  ['pull', txn.bnf.to_s, "--network=#{Shellwords.escape(opts['network'])}", '--quiet-if-absent'] +
166
- (opts['deep'] ? ['--deep'] : []) +
167
+ ["--depth=#{opts['depth'] - 1}"] +
167
168
  (opts['no-baseline'] ? ['--no-baseline'] : []) +
168
169
  ["--trusted=#{Shellwords.escape(opts['trusted'])}"]
169
170
  )
@@ -172,7 +173,7 @@ into #{@wallets.acq(id, &:mnemo)} in #{Age.new(start, limit: 0.1 + cps.count * 0
172
173
  end
173
174
  else
174
175
  patch.join(wallet, ledger: opts['ledger'], baseline: baseline) do |txn|
175
- @log.debug("Paying wallet #{txn.bnf} file is in question but it's not a deep MERGE: #{txn.to_text}")
176
+ @log.debug("Paying wallet #{txn.bnf} is incomplete but there is not enough depth to PULL: #{txn.to_text}")
176
177
  false
177
178
  end
178
179
  end
@@ -45,6 +45,8 @@ module Zold
45
45
  @log = log
46
46
  end
47
47
 
48
+ # Sends a payment and returns the transaction just created in the
49
+ # paying wallet, an instance of Zold::Txn
48
50
  def run(args = [])
49
51
  opts = Slop.parse(args, help: true, suppress_errors: true) do |o|
50
52
  o.banner = "Usage: zold pay wallet target amount [details] [options]
@@ -101,12 +103,13 @@ Available options:"
101
103
  amount = amount(mine[2].strip)
102
104
  details = mine[3] || '-'
103
105
  taxes(id, opts)
104
- @wallets.acq(id, exclusive: true) do |from|
106
+ txn = @wallets.acq(id, exclusive: true) do |from|
105
107
  pay(from, invoice, amount, details, opts)
106
108
  end
107
109
  return if opts['skip-propagate']
108
110
  require_relative 'propagate'
109
111
  Propagate.new(wallets: @wallets, log: @log).run(['propagate', id.to_s])
112
+ txn
110
113
  end
111
114
 
112
115
  private
@@ -473,7 +473,7 @@ this is not a normal behavior, you may want to report a bug to our GitHub reposi
473
473
  title: '/journal',
474
474
  description: 'The journal',
475
475
  id: params[:id],
476
- files: DirItems.new(settings.journal_dir).fetch.sort.reverse.select do |f|
476
+ files: DirItems.new(settings.journal_dir).fetch.sort.reverse.take(256).select do |f|
477
477
  !params[:id] || f.include?(params[:id])
478
478
  end,
479
479
  dir: settings.journal_dir
@@ -75,10 +75,10 @@ module Zold
75
75
  end
76
76
 
77
77
  # Returns a list of modifed wallets (as Zold::Id)
78
- def push(id, body, wallets, log)
78
+ def push(id, body, wallets, log, lifetime: 6)
79
79
  DirItems.new(@dir).fetch.each do |f|
80
80
  f = File.join(@dir, f)
81
- File.delete(f) if File.mtime(f) < Time.now - 24 * 60 * 60
81
+ File.delete(f) if File.mtime(f) < Time.now - lifetime * 60 * 60
82
82
  end
83
83
  journal = File.join(@dir, "#{Time.now.utc.iso8601.gsub(/[^0-9]/, '-')}-#{id}")
84
84
  jlog = Logger.new(journal)
@@ -87,13 +87,12 @@ module Zold
87
87
  def merge(id, copies, wallets, log)
88
88
  Tempfile.open do |f|
89
89
  modified = Tempfile.open do |t|
90
- # host, port = @address.split(':')
90
+ host, port = @address.split(':')
91
91
  Merge.new(wallets: wallets, remotes: @remotes, copies: copies.root, log: log).run(
92
92
  ['merge', id.to_s, "--ledger=#{Shellwords.escape(f.path)}"] +
93
93
  ["--trusted=#{Shellwords.escape(t.path)}"] +
94
- ["--network=#{Shellwords.escape(@network)}"]
95
- # Uncomment this line ASAP:
96
- # (@remotes.master?(host, port.to_i) ? ['--no-baseline', '--deep'] : [])
94
+ ["--network=#{Shellwords.escape(@network)}"] +
95
+ (@remotes.master?(host, port.to_i) ? ['--no-baseline', '--depth=4'] : [])
97
96
  )
98
97
  end
99
98
  @mutex.synchronize do
data/lib/zold/remotes.rb CHANGED
@@ -131,6 +131,10 @@ at #{response.headers['X-Zold-Path']}"
131
131
  []
132
132
  end
133
133
 
134
+ def master?(_, _)
135
+ true
136
+ end
137
+
134
138
  def iterate(_)
135
139
  # Nothing to do here
136
140
  end
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.23'
28
+ VERSION = '0.29.24'
29
29
  PROTOCOL = 2
30
30
  REPO = 'zold-io/zold'
31
31
  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.29.23
4
+ version: 0.29.24
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-03-19 00:00:00.000000000 Z
11
+ date: 2019-03-20 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: backtrace
@@ -798,7 +798,7 @@ licenses:
798
798
  - MIT
799
799
  metadata: {}
800
800
  post_install_message: |-
801
- Thanks for installing Zold 0.29.23!
801
+ Thanks for installing Zold 0.29.24!
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