zold 0.20.2 → 0.20.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/zold/commands/fetch.rb +1 -2
- data/lib/zold/copies.rb +4 -2
- data/lib/zold/head.rb +2 -3
- data/lib/zold/node/farm.rb +1 -2
- data/lib/zold/patch.rb +3 -2
- data/lib/zold/txn.rb +1 -1
- data/lib/zold/txns.rb +2 -1
- data/lib/zold/version.rb +1 -1
- data/lib/zold/wallet.rb +1 -1
- data/test/node/test_farm.rb +2 -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: 894d41fc051b31c71d31c13d24e288cc73186e4f01c43bc495765fca9254c5a2
|
4
|
+
data.tar.gz: e0d8367e208dd8cf78960a617f5d24ff4ff281e91401c312696e8c4dd6904db7
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 065e309f3cb221272695ca5a963fe2814b1c17498a0f7c70c368d9b4c281e9faafee6fe6ffbbe182791ea27bb327854540be9c711ac1ca6fcbebcaf199212419
|
7
|
+
data.tar.gz: 54ba0d26ab73db4c09d23bbd36b6074a107ae2c5c9a3b3ecc38b67d09a5be7b670a1b3406989e26eeee0195ac7278deb3f8ee18cc91a33dba4a6cb7b9184252b
|
data/lib/zold/commands/fetch.rb
CHANGED
@@ -149,8 +149,7 @@ run 'zold remote update' or use --tolerate-quorum=1"
|
|
149
149
|
r.assert_score_ownership(score)
|
150
150
|
r.assert_score_strength(score) unless opts['ignore-score-weakness']
|
151
151
|
Tempfile.open(['', Wallet::EXT]) do |f|
|
152
|
-
|
153
|
-
IO.write(f, body)
|
152
|
+
IO.write(f, json['body'])
|
154
153
|
wallet = Wallet.new(f.path)
|
155
154
|
wallet.refurbish
|
156
155
|
if wallet.protocol != Zold::PROTOCOL
|
data/lib/zold/copies.rb
CHANGED
@@ -21,6 +21,7 @@
|
|
21
21
|
# SOFTWARE.
|
22
22
|
|
23
23
|
require 'time'
|
24
|
+
require 'openssl'
|
24
25
|
require 'csv'
|
25
26
|
require 'futex'
|
26
27
|
require 'backtrace'
|
@@ -97,12 +98,13 @@ module Zold
|
|
97
98
|
raise "Time must be in the past: #{time}" if time > Time.now
|
98
99
|
raise 'Score must be Integer' unless score.is_a?(Integer)
|
99
100
|
raise "Score can't be negative: #{score}" if score.negative?
|
101
|
+
FileUtils.mkdir_p(@dir)
|
100
102
|
Futex.new(file, log: @log).open do
|
101
|
-
FileUtils.mkdir_p(@dir)
|
102
103
|
list = load
|
103
104
|
target = list.find do |s|
|
104
105
|
f = File.join(@dir, "#{s[:name]}#{Copies::EXT}")
|
105
|
-
|
106
|
+
digest = OpenSSL::Digest::SHA256.new(content).hexdigest
|
107
|
+
File.exist?(f) && OpenSSL::Digest::SHA256.file(f).hexdigest == digest
|
106
108
|
end
|
107
109
|
if target.nil?
|
108
110
|
max = DirItems.new(@dir).fetch
|
data/lib/zold/head.rb
CHANGED
@@ -39,10 +39,9 @@ module Zold
|
|
39
39
|
|
40
40
|
def fetch
|
41
41
|
raise "Wallet file '#{@file}' is absent" unless File.exist?(@file)
|
42
|
-
lines = IO.
|
43
|
-
# lines = ['', '', '0123456701234567', '']
|
42
|
+
lines = IO.readlines(@file, "\n").take(4)
|
44
43
|
raise "Not enough lines in #{@file}, just #{lines.count}" if lines.count < 4
|
45
|
-
lines
|
44
|
+
lines
|
46
45
|
end
|
47
46
|
end
|
48
47
|
|
data/lib/zold/node/farm.rb
CHANGED
@@ -204,8 +204,7 @@ at #{host}:#{port}, strength is #{@strength}")
|
|
204
204
|
|
205
205
|
def load
|
206
206
|
return [] unless File.exist?(@cache)
|
207
|
-
|
208
|
-
body.split(/\n/).reject(&:empty?).map do |t|
|
207
|
+
Futex.new(@cache).open(false) { |f| IO.readlines(f, "\n") }.reject(&:empty?).map do |t|
|
209
208
|
Score.parse(t)
|
210
209
|
rescue StandardError => e
|
211
210
|
@log.error(Backtrace.new(e).to_s)
|
data/lib/zold/patch.rb
CHANGED
@@ -20,6 +20,7 @@
|
|
20
20
|
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
21
21
|
# SOFTWARE.
|
22
22
|
|
23
|
+
require 'openssl'
|
23
24
|
require_relative 'log'
|
24
25
|
require_relative 'wallet'
|
25
26
|
require_relative 'signature'
|
@@ -132,7 +133,7 @@ doesn't have this transaction: \"#{txn.to_text}\"")
|
|
132
133
|
def save(file, overwrite: false)
|
133
134
|
raise 'You have to join at least one wallet in' if empty?
|
134
135
|
before = ''
|
135
|
-
before =
|
136
|
+
before = OpenSSL::Digest::SHA256.file(file).hexdigest if File.exist?(file)
|
136
137
|
wallet = Wallet.new(file)
|
137
138
|
wallet.init(@id, @key, overwrite: overwrite, network: @network)
|
138
139
|
File.open(file, 'a') do |f|
|
@@ -141,7 +142,7 @@ doesn't have this transaction: \"#{txn.to_text}\"")
|
|
141
142
|
end
|
142
143
|
end
|
143
144
|
wallet.refurbish
|
144
|
-
after =
|
145
|
+
after = OpenSSL::Digest::SHA256.file(file).hexdigest
|
145
146
|
before != after
|
146
147
|
end
|
147
148
|
end
|
data/lib/zold/txn.rb
CHANGED
@@ -154,7 +154,7 @@ module Zold
|
|
154
154
|
def self.parse(line, idx = 0)
|
155
155
|
clean = line.strip
|
156
156
|
parts = PTN.match(clean)
|
157
|
-
raise "Invalid line ##{idx}: #{line.inspect} #{
|
157
|
+
raise "Invalid line ##{idx}: #{line.inspect} (doesn't match #{PTN})" unless parts
|
158
158
|
txn = Txn.new(
|
159
159
|
Hexnum.parse(parts[:id]).to_i,
|
160
160
|
parse_time(parts[:date]),
|
data/lib/zold/txns.rb
CHANGED
@@ -39,9 +39,10 @@ module Zold
|
|
39
39
|
|
40
40
|
def fetch
|
41
41
|
raise "Wallet file '#{@file}' is absent" unless File.exist?(@file)
|
42
|
-
lines = IO.
|
42
|
+
lines = IO.readlines(@file, "\n")
|
43
43
|
raise "Not enough lines in #{@file}, just #{lines.count}" if lines.count < 4
|
44
44
|
lines.drop(5)
|
45
|
+
.reject { |t| t.strip.empty? }
|
45
46
|
.each_with_index
|
46
47
|
.map { |line, i| Txn.parse(line, i + 6) }
|
47
48
|
.sort
|
data/lib/zold/version.rb
CHANGED
data/lib/zold/wallet.rb
CHANGED
data/test/node/test_farm.rb
CHANGED
@@ -150,8 +150,8 @@ class FarmTest < Zold::Test
|
|
150
150
|
Dir.mktmpdir do |dir|
|
151
151
|
file = File.join(dir, 'corrupted_farm')
|
152
152
|
[
|
153
|
-
'
|
154
|
-
'some garbage'
|
153
|
+
'some garbage',
|
154
|
+
'some other garbage'
|
155
155
|
].each do |score_garbage_line|
|
156
156
|
valid_score = Zold::Score.new(
|
157
157
|
time: Time.parse('2017-07-19T21:24:51Z'),
|
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.20.
|
4
|
+
version: 0.20.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Yegor Bugayenko
|
@@ -692,7 +692,7 @@ licenses:
|
|
692
692
|
- MIT
|
693
693
|
metadata: {}
|
694
694
|
post_install_message: |-
|
695
|
-
Thanks for installing Zold 0.20.
|
695
|
+
Thanks for installing Zold 0.20.3!
|
696
696
|
Study our White Paper: https://papers.zold.io/wp.pdf
|
697
697
|
Read our blog posts: https://blog.zold.io
|
698
698
|
Try online wallet at: https://wts.zold.io
|