zold 0.21.0 → 0.21.1
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 +4 -4
- data/.rultor.yml +1 -1
- data/Guardfile +9 -0
- data/lib/zold/commands/node.rb +10 -2
- data/lib/zold/node/front.rb +2 -3
- data/lib/zold/remotes.rb +27 -19
- data/lib/zold/version.rb +1 -1
- data/test/test_http.rb +2 -8
- data/test/test_remotes.rb +13 -0
- data/zold.gemspec +4 -1
- metadata +48 -5
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 4a04c52513e6e44079e0e39a5245cf1075fe740990fa73b94c44217214bb0272
|
4
|
+
data.tar.gz: f9b6b3183b4f587184557dfa88af90a45511098af6b9682e08a113976a618b24
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: dc7ca238f71aa8c628c535f5e65a017c24293cedba569995ec8e0006bf082c3f2ccf2049e85f67bfbc59039fe3e898ed3438a8ed26a389010f18972a1d9e1005
|
7
|
+
data.tar.gz: 9d2a309a544d9b0199bd732edb15ca08458e76b293f75dbe90d498f1eda6457927f83f7818aec3b5dcfb53e64a5c5764fbcfd0e00d827e0be8f839691e7c9025
|
data/.rultor.yml
CHANGED
@@ -14,7 +14,7 @@ release:
|
|
14
14
|
[[ "${tag}" =~ ^[0-9]+\.[0-9]+\.[0-9]+$ ]] || exit -1
|
15
15
|
# gem build zold.gemspec
|
16
16
|
# gem install --local zold-0.0.0.gem
|
17
|
-
# zold --version | grep -vq '0.0.0' && exit 1
|
17
|
+
# zold --version | grep -vq '0.0.0' && exit -1
|
18
18
|
# zold remote update
|
19
19
|
sed -i "s/0\.0\.0/${tag}/g" lib/zold/version.rb
|
20
20
|
bundle install --no-color
|
data/Guardfile
ADDED
@@ -0,0 +1,9 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
# Guardfile for Zold
|
4
|
+
guard :minitest, all_after_pass: false, all_on_start: false do
|
5
|
+
# with Minitest::Unit
|
6
|
+
watch(%r{^test/(.*)\/?test_(.*)\.rb$})
|
7
|
+
watch(%r{^lib/zold/(.*/)?([^/]+)\.rb$}) { |m| "test/#{m[1]}test_#{m[2]}.rb" }
|
8
|
+
watch(%r{^test/test_helper\.rb$}) { 'test' }
|
9
|
+
end
|
data/lib/zold/commands/node.rb
CHANGED
@@ -149,8 +149,8 @@ module Zold
|
|
149
149
|
'Skip Out Of Memory check and never exit, no matter how much RAM is consumed',
|
150
150
|
default: false
|
151
151
|
o.integer '--oom-limit',
|
152
|
-
|
153
|
-
default:
|
152
|
+
"Maximum amount of memory we can consume, quit if we take more than that, in Mb (default: #{oom_limit})",
|
153
|
+
default: oom_limit
|
154
154
|
o.integer '--queue-limit',
|
155
155
|
'The maximum number of wallets to be accepted via PUSH and stored in the queue (default: 256)',
|
156
156
|
default: 256
|
@@ -440,6 +440,14 @@ module Zold
|
|
440
440
|
addr.ip_address
|
441
441
|
end
|
442
442
|
|
443
|
+
def oom_limit
|
444
|
+
require 'total'
|
445
|
+
Total::Mem.new.bytes / (1024 * 1024) / 2
|
446
|
+
rescue Total::CantDetect => e
|
447
|
+
@log.error(e.message)
|
448
|
+
512
|
449
|
+
end
|
450
|
+
|
443
451
|
# Log facility for nohup
|
444
452
|
class NohupLog
|
445
453
|
def initialize(file, max)
|
data/lib/zold/node/front.rb
CHANGED
@@ -244,12 +244,12 @@ this is not a normal behavior, you may want to report a bug to our GitHub reposi
|
|
244
244
|
protocol: settings.protocol,
|
245
245
|
id: wallet.id.to_s,
|
246
246
|
score: score.to_h,
|
247
|
-
wallets: total_wallets,
|
248
247
|
mtime: wallet.mtime.utc.iso8601,
|
249
248
|
size: wallet.size,
|
250
249
|
digest: wallet.digest,
|
251
250
|
copies: Copies.new(File.join(settings.copies, wallet.id)).all.count,
|
252
|
-
balance: wallet.balance.to_i
|
251
|
+
balance: wallet.balance.to_i,
|
252
|
+
txns: wallet.txns.count
|
253
253
|
)
|
254
254
|
end
|
255
255
|
end
|
@@ -443,7 +443,6 @@ time to stop; use --skip-oom to never quit")
|
|
443
443
|
end
|
444
444
|
|
445
445
|
def total_wallets
|
446
|
-
return 256 unless settings.opts['no-cache']
|
447
446
|
settings.zache.get(:wallets, lifetime: settings.opts['no-cache'] ? 0 : 60) do
|
448
447
|
settings.wallets.count
|
449
448
|
end
|
data/lib/zold/remotes.rb
CHANGED
@@ -159,33 +159,25 @@ module Zold
|
|
159
159
|
end
|
160
160
|
|
161
161
|
def exists?(host, port = PORT)
|
162
|
-
|
163
|
-
raise 'Host can\'t be nil' if host.nil?
|
164
|
-
raise 'Port can\'t be nil' if port.nil?
|
162
|
+
assert_host_info(host, port)
|
165
163
|
list = Futex.new(@file).open(false) { load }
|
166
164
|
!list.find { |r| r[:host] == host.downcase && r[:port] == port }.nil?
|
167
165
|
end
|
168
166
|
|
169
167
|
def add(host, port = PORT)
|
170
|
-
|
171
|
-
raise 'Host can\'t be empty' if host.empty?
|
172
|
-
raise 'Port can\'t be nil' if port.nil?
|
173
|
-
raise 'Port has to be of type Integer' unless port.is_a?(Integer)
|
174
|
-
raise 'Port can\'t be zero' if port.zero?
|
175
|
-
raise 'Port can\'t be negative' if port.negative?
|
176
|
-
raise 'Port can\'t be over 65536' if port > 0xffff
|
168
|
+
assert_host_info(host, port)
|
177
169
|
modify do |list|
|
178
170
|
list + [{ host: host.downcase, port: port, score: 0, errors: 0 }]
|
179
171
|
end
|
172
|
+
unerror(host, port)
|
180
173
|
end
|
181
174
|
|
182
175
|
def remove(host, port = PORT)
|
183
|
-
|
184
|
-
raise 'Host can\'t be nil' if host.nil?
|
185
|
-
raise 'Port can\'t be nil' if port.nil?
|
176
|
+
assert_host_info(host, port)
|
186
177
|
modify do |list|
|
187
178
|
list.reject { |r| r[:host] == host.downcase && r[:port] == port }
|
188
179
|
end
|
180
|
+
unerror(host, port)
|
189
181
|
end
|
190
182
|
|
191
183
|
# Go through the list of remotes and call a provided block for each
|
@@ -208,6 +200,7 @@ module Zold
|
|
208
200
|
network: @network
|
209
201
|
)
|
210
202
|
raise 'Took too long to execute' if (Time.now - start).round > @timeout
|
203
|
+
unerror(r[:host], r[:port])
|
211
204
|
rescue StandardError => e
|
212
205
|
error(r[:host], r[:port])
|
213
206
|
log.info("#{Rainbow("#{r[:host]}:#{r[:port]}").red}: #{e.message} in #{Age.new(start)}")
|
@@ -218,19 +211,24 @@ module Zold
|
|
218
211
|
end
|
219
212
|
|
220
213
|
def error(host, port = PORT)
|
221
|
-
|
222
|
-
raise 'Port can\'t be nil' if port.nil?
|
223
|
-
raise 'Port has to be of type Integer' unless port.is_a?(Integer)
|
214
|
+
assert_host_info(host, port)
|
224
215
|
if_present(host, port) { |r| r[:errors] += 1 }
|
225
216
|
end
|
226
217
|
|
218
|
+
def unerror(host, port = PORT)
|
219
|
+
assert_host_info(host, port)
|
220
|
+
|
221
|
+
if_present(host, port) do |remote|
|
222
|
+
remote[:errors] -= 1 if (remote[:errors]).positive?
|
223
|
+
end
|
224
|
+
end
|
225
|
+
|
227
226
|
def rescore(host, port, score)
|
228
|
-
|
229
|
-
raise 'Port can\'t be nil' if port.nil?
|
227
|
+
assert_host_info(host, port)
|
230
228
|
raise 'Score can\'t be nil' if score.nil?
|
231
|
-
raise 'Port has to be of type Integer' unless port.is_a?(Integer)
|
232
229
|
raise 'Score has to be of type Integer' unless score.is_a?(Integer)
|
233
230
|
if_present(host, port) { |r| r[:score] = score }
|
231
|
+
unerror(host, port)
|
234
232
|
end
|
235
233
|
|
236
234
|
def mtime
|
@@ -289,5 +287,15 @@ module Zold
|
|
289
287
|
[]
|
290
288
|
end
|
291
289
|
end
|
290
|
+
|
291
|
+
def assert_host_info(host, port)
|
292
|
+
raise 'Host can\'t be nil' if host.nil?
|
293
|
+
raise 'Host can\'t be empty' if host.empty?
|
294
|
+
raise 'Port can\'t be nil' if port.nil?
|
295
|
+
raise 'Port has to be of type Integer' unless port.is_a?(Integer)
|
296
|
+
raise 'Port can\'t be zero' if port.zero?
|
297
|
+
raise 'Port can\'t be negative' if port.negative?
|
298
|
+
raise 'Port can\'t be over 65536' if port > 0xffff
|
299
|
+
end
|
292
300
|
end
|
293
301
|
end
|
data/lib/zold/version.rb
CHANGED
data/test/test_http.rb
CHANGED
@@ -112,23 +112,17 @@ class TestHttp < Zold::Test
|
|
112
112
|
end
|
113
113
|
end
|
114
114
|
|
115
|
-
# @todo #444:30min It's obvious that the test works (I can see that in
|
116
|
-
# the console, but for some weird reason it doesn't work in Minitest. Try
|
117
|
-
# to run it: ruby test/test_http.rb -n test_sends_correct_http_headers
|
118
|
-
# If fails because of PUT HTTP request timeout. Let's find the problem,
|
119
|
-
# fix it, and un-skip the test.
|
120
115
|
def test_sends_correct_http_headers
|
121
|
-
skip
|
122
116
|
WebMock.allow_net_connect!
|
123
117
|
body = ''
|
124
118
|
RandomPort::Pool::SINGLETON.acquire do |port|
|
125
119
|
thread = Thread.start do
|
126
120
|
Zold::VerboseThread.new(test_log).run do
|
127
|
-
server = TCPServer.new(port)
|
121
|
+
server = TCPServer.new('127.0.0.1', port)
|
128
122
|
socket = server.accept
|
129
123
|
loop do
|
130
124
|
line = socket.gets
|
131
|
-
break if line.
|
125
|
+
break if line.eql?("\r\n")
|
132
126
|
test_log.info(line.inspect)
|
133
127
|
body += line
|
134
128
|
end
|
data/test/test_remotes.rb
CHANGED
@@ -261,6 +261,19 @@ class TestRemotes < Zold::Test
|
|
261
261
|
end
|
262
262
|
end
|
263
263
|
|
264
|
+
def test_unerror_remote
|
265
|
+
Dir.mktmpdir do |dir|
|
266
|
+
remotes = Zold::Remotes.new(file: File.join(dir, 'uu-90.csv'))
|
267
|
+
remotes.clean
|
268
|
+
remotes.add('192.168.0.1', 8081)
|
269
|
+
assert_equal remotes.all.last[:errors], 0
|
270
|
+
remotes.error('192.168.0.1', 8081)
|
271
|
+
assert_equal remotes.all.last[:errors], 1
|
272
|
+
remotes.unerror('192.168.0.1', 8081)
|
273
|
+
assert_equal remotes.all.last[:errors], 0
|
274
|
+
end
|
275
|
+
end
|
276
|
+
|
264
277
|
def test_empty_remotes
|
265
278
|
Time.stub :now, Time.mktime(2018, 1, 1) do
|
266
279
|
remotes = Zold::Remotes::Empty.new
|
data/zold.gemspec
CHANGED
@@ -65,7 +65,7 @@ and suggests a different architecture for digital wallet maintenance.'
|
|
65
65
|
s.add_runtime_dependency 'concurrent-ruby', '1.1.3'
|
66
66
|
s.add_runtime_dependency 'cucumber', '3.1.2' # has to stay here for Heroku
|
67
67
|
s.add_runtime_dependency 'diffy', '3.2.1'
|
68
|
-
s.add_runtime_dependency 'futex', '
|
68
|
+
s.add_runtime_dependency 'futex', '0.8.1'
|
69
69
|
s.add_runtime_dependency 'get_process_mem', '~>0.2'
|
70
70
|
s.add_runtime_dependency 'json', '2.1.0'
|
71
71
|
s.add_runtime_dependency 'memory_profiler', '0.9.12'
|
@@ -81,12 +81,15 @@ and suggests a different architecture for digital wallet maintenance.'
|
|
81
81
|
s.add_runtime_dependency 'sys-proctable', '1.2.1'
|
82
82
|
s.add_runtime_dependency 'thin', '1.7.2'
|
83
83
|
s.add_runtime_dependency 'threads', '>=0.3'
|
84
|
+
s.add_runtime_dependency 'total', '>=0.2.0'
|
84
85
|
s.add_runtime_dependency 'typhoeus', '1.3.1'
|
85
86
|
s.add_runtime_dependency 'usagewatch_ext', '0.2.1'
|
86
87
|
s.add_runtime_dependency 'xcop', '>=0.6'
|
87
88
|
s.add_runtime_dependency 'zache', '>=0.7.0'
|
88
89
|
s.add_runtime_dependency 'zold-score', '0.4.4'
|
89
90
|
s.add_development_dependency 'codecov', '0.1.13'
|
91
|
+
s.add_development_dependency 'guard', '2.15.0'
|
92
|
+
s.add_development_dependency 'guard-minitest', '2.4.6'
|
90
93
|
s.add_development_dependency 'minitest', '5.11.3'
|
91
94
|
s.add_development_dependency 'minitest-fail-fast', '0.1.0'
|
92
95
|
s.add_development_dependency 'minitest-hooks', '1.5.0'
|
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.21.
|
4
|
+
version: 0.21.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Yegor Bugayenko
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2018-12-
|
11
|
+
date: 2018-12-28 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: backtrace
|
@@ -70,14 +70,14 @@ dependencies:
|
|
70
70
|
name: futex
|
71
71
|
requirement: !ruby/object:Gem::Requirement
|
72
72
|
requirements:
|
73
|
-
- -
|
73
|
+
- - '='
|
74
74
|
- !ruby/object:Gem::Version
|
75
75
|
version: 0.8.1
|
76
76
|
type: :runtime
|
77
77
|
prerelease: false
|
78
78
|
version_requirements: !ruby/object:Gem::Requirement
|
79
79
|
requirements:
|
80
|
-
- -
|
80
|
+
- - '='
|
81
81
|
- !ruby/object:Gem::Version
|
82
82
|
version: 0.8.1
|
83
83
|
- !ruby/object:Gem::Dependency
|
@@ -290,6 +290,20 @@ dependencies:
|
|
290
290
|
- - ">="
|
291
291
|
- !ruby/object:Gem::Version
|
292
292
|
version: '0.3'
|
293
|
+
- !ruby/object:Gem::Dependency
|
294
|
+
name: total
|
295
|
+
requirement: !ruby/object:Gem::Requirement
|
296
|
+
requirements:
|
297
|
+
- - ">="
|
298
|
+
- !ruby/object:Gem::Version
|
299
|
+
version: 0.2.0
|
300
|
+
type: :runtime
|
301
|
+
prerelease: false
|
302
|
+
version_requirements: !ruby/object:Gem::Requirement
|
303
|
+
requirements:
|
304
|
+
- - ">="
|
305
|
+
- !ruby/object:Gem::Version
|
306
|
+
version: 0.2.0
|
293
307
|
- !ruby/object:Gem::Dependency
|
294
308
|
name: typhoeus
|
295
309
|
requirement: !ruby/object:Gem::Requirement
|
@@ -374,6 +388,34 @@ dependencies:
|
|
374
388
|
- - '='
|
375
389
|
- !ruby/object:Gem::Version
|
376
390
|
version: 0.1.13
|
391
|
+
- !ruby/object:Gem::Dependency
|
392
|
+
name: guard
|
393
|
+
requirement: !ruby/object:Gem::Requirement
|
394
|
+
requirements:
|
395
|
+
- - '='
|
396
|
+
- !ruby/object:Gem::Version
|
397
|
+
version: 2.15.0
|
398
|
+
type: :development
|
399
|
+
prerelease: false
|
400
|
+
version_requirements: !ruby/object:Gem::Requirement
|
401
|
+
requirements:
|
402
|
+
- - '='
|
403
|
+
- !ruby/object:Gem::Version
|
404
|
+
version: 2.15.0
|
405
|
+
- !ruby/object:Gem::Dependency
|
406
|
+
name: guard-minitest
|
407
|
+
requirement: !ruby/object:Gem::Requirement
|
408
|
+
requirements:
|
409
|
+
- - '='
|
410
|
+
- !ruby/object:Gem::Version
|
411
|
+
version: 2.4.6
|
412
|
+
type: :development
|
413
|
+
prerelease: false
|
414
|
+
version_requirements: !ruby/object:Gem::Requirement
|
415
|
+
requirements:
|
416
|
+
- - '='
|
417
|
+
- !ruby/object:Gem::Version
|
418
|
+
version: 2.4.6
|
377
419
|
- !ruby/object:Gem::Dependency
|
378
420
|
name: minitest
|
379
421
|
requirement: !ruby/object:Gem::Requirement
|
@@ -504,6 +546,7 @@ files:
|
|
504
546
|
- ".simplecov"
|
505
547
|
- ".travis.yml"
|
506
548
|
- Gemfile
|
549
|
+
- Guardfile
|
507
550
|
- INSTALL.md
|
508
551
|
- LICENSE.txt
|
509
552
|
- Procfile
|
@@ -706,7 +749,7 @@ licenses:
|
|
706
749
|
- MIT
|
707
750
|
metadata: {}
|
708
751
|
post_install_message: |-
|
709
|
-
Thanks for installing Zold 0.21.
|
752
|
+
Thanks for installing Zold 0.21.1!
|
710
753
|
Study our White Paper: https://papers.zold.io/wp.pdf
|
711
754
|
Read our blog posts: https://blog.zold.io
|
712
755
|
Try online wallet at: https://wts.zold.io
|