zold 0.29.22 → 0.29.23
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/fixtures/merge/into_no_wallet/opts +1 -1
- data/fixtures/merge/missed_wallets/opts +3 -1
- data/fixtures/merge/unconfirmed_income/opts +3 -1
- data/lib/zold/commands/merge.rb +15 -14
- data/lib/zold/node/pipeline.rb +4 -1
- data/lib/zold/patch.rb +29 -15
- data/lib/zold/version.rb +1 -1
- data/test/test_copies.rb +4 -2
- 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: 889105e0d182da51bc1e5f1404ac8a89e761ccbe3a01c2d8927093d5cbbea4b7
|
4
|
+
data.tar.gz: da4dc45dd27825ea6f36d361f9d8e0617bac70f3d8d333a1471b477987498b75
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 4378c9164cde07bc3d52df96df215632ef29c871c95cb9e6838550bd4e6b72761d3f3a8e7a73cce3e4f7825b38eb4f2d939d9ffbf49cd05edc15514c8ad32ff0
|
7
|
+
data.tar.gz: 39a8d2951f30122c8abe0da442800c1bac410cc0daeafc8000ac1b7ee5dedbfa179301778c2d44692fefcc50f69effd4b6aa7a42ef64e72d3771070d5994c43d
|
@@ -1 +1 @@
|
|
1
|
-
--
|
1
|
+
--verbose
|
data/lib/zold/commands/merge.rb
CHANGED
@@ -63,15 +63,15 @@ 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 '--shallow',
|
67
|
-
'Don\'t try to pull other wallets if their confirmations are required',
|
68
|
-
default: false
|
69
66
|
o.bool '--deep',
|
70
67
|
'Try to pull other wallets if their confirmations are required, as deep as possible',
|
71
68
|
default: false
|
72
69
|
o.bool '--allow-negative-balance',
|
73
70
|
'Don\'t check for the negative balance of the wallet after the merge',
|
74
71
|
default: false
|
72
|
+
o.bool '--no-baseline',
|
73
|
+
'Don\'t treat the highest score master copy as trustable baseline',
|
74
|
+
default: false
|
75
75
|
o.string '--ledger',
|
76
76
|
'The name of the file where all new negative transactions will be recorded (default: /dev/null)',
|
77
77
|
default: '/dev/null'
|
@@ -80,7 +80,7 @@ Available options:"
|
|
80
80
|
default: '/dev/null'
|
81
81
|
o.integer '--trusted-max',
|
82
82
|
'The maximum amount of trusted wallets we can see in the list',
|
83
|
-
default:
|
83
|
+
default: 128
|
84
84
|
o.string '--network',
|
85
85
|
'The name of the network we work in',
|
86
86
|
default: 'test'
|
@@ -120,7 +120,7 @@ Available options:"
|
|
120
120
|
cps.each_with_index do |c, idx|
|
121
121
|
wallet = Wallet.new(c[:path])
|
122
122
|
name = "#{c[:name]}/#{idx}/#{c[:score]}"
|
123
|
-
merge_one(opts, patch, wallet, name)
|
123
|
+
merge_one(opts, patch, wallet, name, baseline: idx.zero? && c[:master] && !opts['no-baseline'])
|
124
124
|
score += c[:score]
|
125
125
|
end
|
126
126
|
@wallets.acq(id) do |w|
|
@@ -148,16 +148,11 @@ into #{@wallets.acq(id, &:mnemo)} in #{Age.new(start, limit: 0.1 + cps.count * 0
|
|
148
148
|
modified
|
149
149
|
end
|
150
150
|
|
151
|
-
def merge_one(opts, patch, wallet, name)
|
151
|
+
def merge_one(opts, patch, wallet, name, baseline: false)
|
152
152
|
start = Time.now
|
153
153
|
@log.debug("Building a patch for #{wallet.id} from remote copy ##{name} with #{wallet.mnemo}...")
|
154
|
-
if opts['
|
155
|
-
patch.join(wallet, ledger: opts['ledger']) do |txn|
|
156
|
-
@log.debug("Paying wallet #{txn.bnf} file is in question but it's a \"shallow\" MERGE: #{txn.to_text}")
|
157
|
-
false
|
158
|
-
end
|
159
|
-
else
|
160
|
-
patch.join(wallet, ledger: opts['ledger']) do |txn|
|
154
|
+
if opts['deep']
|
155
|
+
patch.join(wallet, ledger: opts['ledger'], baseline: baseline) do |txn|
|
161
156
|
trusted = IO.read(opts['trusted']).split(',')
|
162
157
|
if trusted.include?(txn.bnf.to_s)
|
163
158
|
@log.debug("Won't PULL #{txn.bnf} since it is already trusted, among #{trusted.count} others")
|
@@ -168,12 +163,18 @@ into #{@wallets.acq(id, &:mnemo)} in #{Age.new(start, limit: 0.1 + cps.count * 0
|
|
168
163
|
IO.write(opts['trusted'], (trusted + [txn.bnf.to_s]).sort.uniq.join(','))
|
169
164
|
Pull.new(wallets: @wallets, remotes: @remotes, copies: @copies, log: @log).run(
|
170
165
|
['pull', txn.bnf.to_s, "--network=#{Shellwords.escape(opts['network'])}", '--quiet-if-absent'] +
|
171
|
-
(opts['deep'] ? ['--deep'] : [
|
166
|
+
(opts['deep'] ? ['--deep'] : []) +
|
167
|
+
(opts['no-baseline'] ? ['--no-baseline'] : []) +
|
172
168
|
["--trusted=#{Shellwords.escape(opts['trusted'])}"]
|
173
169
|
)
|
174
170
|
end
|
175
171
|
true
|
176
172
|
end
|
173
|
+
else
|
174
|
+
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
|
+
false
|
177
|
+
end
|
177
178
|
end
|
178
179
|
@log.debug("Copy ##{name} of #{wallet.id} merged in #{Age.new(start)}: #{patch}")
|
179
180
|
rescue StandardError => e
|
data/lib/zold/node/pipeline.rb
CHANGED
@@ -87,10 +87,13 @@ 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
91
|
Merge.new(wallets: wallets, remotes: @remotes, copies: copies.root, log: log).run(
|
91
92
|
['merge', id.to_s, "--ledger=#{Shellwords.escape(f.path)}"] +
|
92
|
-
["--trusted=#{Shellwords.escape(t.path)}"
|
93
|
+
["--trusted=#{Shellwords.escape(t.path)}"] +
|
93
94
|
["--network=#{Shellwords.escape(@network)}"]
|
95
|
+
# Uncomment this line ASAP:
|
96
|
+
# (@remotes.master?(host, port.to_i) ? ['--no-baseline', '--deep'] : [])
|
94
97
|
)
|
95
98
|
end
|
96
99
|
@mutex.synchronize do
|
data/lib/zold/patch.rb
CHANGED
@@ -65,7 +65,11 @@ module Zold
|
|
65
65
|
# not present, it's a failure, don't accept the transaction. FALSE will mean
|
66
66
|
# that the transaction should be accepted, even if the paying wallet is
|
67
67
|
# absent.
|
68
|
-
|
68
|
+
#
|
69
|
+
# The "baseline" flag, when set to TRUE, means that we should NOT validate
|
70
|
+
# the presence of positive incoming transactions in their correspondent
|
71
|
+
# wallets. We shall just trust them.
|
72
|
+
def join(wallet, ledger: '/dev/null', baseline: false)
|
69
73
|
if @id.nil?
|
70
74
|
@id = wallet.id
|
71
75
|
@key = wallet.key
|
@@ -115,25 +119,35 @@ with a new one \"#{txn.to_text}\" from #{wallet.mnemo}")
|
|
115
119
|
next
|
116
120
|
end
|
117
121
|
unless @wallets.acq(txn.bnf, &:exists?)
|
118
|
-
|
119
|
-
|
120
|
-
|
121
|
-
|
122
|
-
|
122
|
+
if baseline
|
123
|
+
@log.debug("Paying wallet #{txn.bnf} is absent, but the txn in in the baseline: \"#{txn.to_text}\"")
|
124
|
+
else
|
125
|
+
next if pulled.include?(txn.bnf)
|
126
|
+
pulled << txn.bnf
|
127
|
+
if yield(txn) && !@wallets.acq(txn.bnf, &:exists?)
|
128
|
+
@log.error("Paying wallet #{txn.bnf} file is absent even after PULL: \"#{txn.to_text}\"")
|
129
|
+
next
|
130
|
+
end
|
123
131
|
end
|
124
132
|
end
|
125
|
-
if @wallets.acq(txn.bnf, &:exists?) &&
|
126
|
-
|
133
|
+
if @wallets.acq(txn.bnf, &:exists?) &&
|
134
|
+
!@wallets.acq(txn.bnf) { |p| p.includes_negative?(txn.id, wallet.id) }
|
135
|
+
if baseline
|
127
136
|
@log.debug("The beneficiary #{@wallets.acq(txn.bnf, &:mnemo)} of #{@id} \
|
137
|
+
doesn't have this transaction, but we trust it, since it's a baseline: \"#{txn.to_text}\"")
|
138
|
+
else
|
139
|
+
if pulled.include?(txn.bnf)
|
140
|
+
@log.debug("The beneficiary #{@wallets.acq(txn.bnf, &:mnemo)} of #{@id} \
|
128
141
|
doesn't have this transaction: \"#{txn.to_text}\"")
|
129
|
-
|
130
|
-
|
131
|
-
|
132
|
-
|
133
|
-
|
134
|
-
|
142
|
+
next
|
143
|
+
end
|
144
|
+
pulled << txn.bnf
|
145
|
+
yield(txn)
|
146
|
+
unless @wallets.acq(txn.bnf) { |p| p.includes_negative?(txn.id, wallet.id) }
|
147
|
+
@log.debug("The beneficiary #{@wallets.acq(txn.bnf, &:mnemo)} of #{@id} \
|
135
148
|
doesn't have this transaction: \"#{txn.to_text}\"")
|
136
|
-
|
149
|
+
next
|
150
|
+
end
|
137
151
|
end
|
138
152
|
end
|
139
153
|
end
|
data/lib/zold/version.rb
CHANGED
data/test/test_copies.rb
CHANGED
@@ -73,8 +73,10 @@ class TestCopies < Zold::Test
|
|
73
73
|
def test_master_first
|
74
74
|
Dir.mktmpdir do |dir|
|
75
75
|
copies = Zold::Copies.new(File.join(dir, 'my/a/copies-2'), log: test_log)
|
76
|
-
copies.add(content('z1'), '
|
77
|
-
copies.add(content('z2'), '
|
76
|
+
copies.add(content('z1'), 'edge-1', 80, 100, master: false)
|
77
|
+
copies.add(content('z2'), 'master', 80, 1, master: true)
|
78
|
+
copies.add(content('z1'), 'edge-2', 80, 50, master: false)
|
79
|
+
copies.add(content('z1'), 'edge-3', 80, 400, master: false)
|
78
80
|
assert(copies.all[0][:master])
|
79
81
|
end
|
80
82
|
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.
|
4
|
+
version: 0.29.23
|
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.
|
801
|
+
Thanks for installing Zold 0.29.23!
|
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
|