zold 0.18.5 → 0.18.6
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/node.rb +1 -3
- data/lib/zold/metronome.rb +4 -5
- data/lib/zold/node/async_entrance.rb +3 -0
- data/lib/zold/node/farm.rb +7 -6
- data/lib/zold/node/front.rb +3 -1
- data/lib/zold/remotes.rb +1 -1
- data/lib/zold/version.rb +2 -1
- metadata +2 -5
- data/lib/zold/commands/routines/spread.rb +0 -62
- data/test/commands/routines/test_spread.rb +0 -45
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 3cef493a42202430232e9c904a25258bdf6c59336c3f6732687b1412713f93d1
|
4
|
+
data.tar.gz: 8ff76340ba5810cf0ccb241c61505fcc1c8f9b0c7efa49b40f49fb312ff0370f
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 5ffcaa34424091b2f97ce0f3a12cca71b983c32332a7ddeef69d6cdfd89ed507a8539f4baa2cf909ec30675721aea4b7add652fba881192113df3b97b6fd1cd2
|
7
|
+
data.tar.gz: b1e80e8a217ba00c6a1c6b15a8efc48c1687f7295607c529a2d322b763fd001d019bb87411e3815532f7a9117f7e41f88a137e3e666c74c20fb42db401e14986
|
data/lib/zold/commands/node.rb
CHANGED
@@ -274,10 +274,10 @@ module Zold
|
|
274
274
|
@log.info("Starting up the web front at http://#{host}:#{opts[:port]}...")
|
275
275
|
Front.run!
|
276
276
|
@log.info("The web front stopped at http://#{host}:#{opts[:port]}")
|
277
|
-
@log.info('Thanks for helping Zold network!')
|
278
277
|
end
|
279
278
|
end
|
280
279
|
end
|
280
|
+
@log.info('Thanks for helping Zold network!')
|
281
281
|
end
|
282
282
|
|
283
283
|
private
|
@@ -363,8 +363,6 @@ module Zold
|
|
363
363
|
@log.info('Metronome hasn\'t been started because of --no-metronome')
|
364
364
|
return metronome
|
365
365
|
end
|
366
|
-
require_relative 'routines/spread'
|
367
|
-
metronome.add(Routines::Spread.new(opts, @wallets, @remotes, log: @log))
|
368
366
|
require_relative 'routines/gc'
|
369
367
|
metronome.add(Routines::Gc.new(opts, @wallets, log: @log))
|
370
368
|
unless opts['standalone']
|
data/lib/zold/metronome.rb
CHANGED
@@ -87,11 +87,10 @@ module Zold
|
|
87
87
|
ensure
|
88
88
|
start = Time.now
|
89
89
|
unless @threads.empty?
|
90
|
-
@log.info("Stopping the metronome with #{@threads.count} threads
|
91
|
-
@threads.each
|
92
|
-
|
93
|
-
|
94
|
-
end
|
90
|
+
@log.info("Stopping the metronome with #{@threads.count} threads...")
|
91
|
+
@threads.each(&:kill)
|
92
|
+
@threads.each(&:join)
|
93
|
+
@log.info("Metronome #{@threads.count} threads killed")
|
95
94
|
end
|
96
95
|
@log.info("Metronome stopped in #{Age.new(start)}, #{@failures.count} failures")
|
97
96
|
end
|
@@ -75,7 +75,10 @@ module Zold
|
|
75
75
|
begin
|
76
76
|
yield(self)
|
77
77
|
ensure
|
78
|
+
@log.info("AsyncEntrance stopping and killing #{@threads.count} threads...")
|
78
79
|
@threads.each(&:kill)
|
80
|
+
@threads.each(&:join)
|
81
|
+
@log.info("AsyncEntrance stopped, #{@threads.count} threads killed")
|
79
82
|
end
|
80
83
|
end
|
81
84
|
end
|
data/lib/zold/node/farm.rb
CHANGED
@@ -93,11 +93,10 @@ module Zold
|
|
93
93
|
].flatten.join("\n\n")
|
94
94
|
end
|
95
95
|
|
96
|
+
# Renders the Farm into JSON to show for the end-user in front.rb.
|
96
97
|
def to_json
|
97
98
|
{
|
98
|
-
threads: @threads.map
|
99
|
-
"#{t.name}/#{t.status}/#{t.alive? ? 'alive' : 'dead'}"
|
100
|
-
end.join(', '),
|
99
|
+
threads: @threads.map { |t| "#{t.name}/#{t.status}/#{t.alive? ? 'alive' : 'dead'}" }.join(', '),
|
101
100
|
pipeline: @pipeline.size,
|
102
101
|
best: best.map(&:to_mnemo).join(', '),
|
103
102
|
farmer: @farmer.class.name
|
@@ -123,7 +122,7 @@ module Zold
|
|
123
122
|
@log.info("#{best.size} scores pre-loaded from #{@cache}, the best is: #{best[0]}")
|
124
123
|
end
|
125
124
|
@threads = (1..threads).map do |t|
|
126
|
-
Thread.
|
125
|
+
Thread.start do
|
127
126
|
Thread.current.thread_variable_set(:tid, t.to_s)
|
128
127
|
Endless.new("f#{t}", log: @log).run do
|
129
128
|
cycle(host, port, threads)
|
@@ -132,7 +131,7 @@ module Zold
|
|
132
131
|
end
|
133
132
|
unless threads.zero?
|
134
133
|
ready = false
|
135
|
-
@threads << Thread.
|
134
|
+
@threads << Thread.start do
|
136
135
|
Endless.new('cleanup', log: @log).run do
|
137
136
|
cleanup(host, port, threads)
|
138
137
|
ready = true
|
@@ -151,8 +150,10 @@ at #{host}:#{port}, strength is #{@strength}")
|
|
151
150
|
begin
|
152
151
|
yield(self)
|
153
152
|
ensure
|
153
|
+
@log.info("Farm stopping with #{threads} threads...")
|
154
154
|
@threads.each(&:kill)
|
155
|
-
@
|
155
|
+
@threads.each(&:join)
|
156
|
+
@log.info("Farm stopped, #{threads} threads killed")
|
156
157
|
end
|
157
158
|
end
|
158
159
|
|
data/lib/zold/node/front.rb
CHANGED
@@ -107,6 +107,7 @@ while #{settings.address} is in '#{settings.opts['network']}'")
|
|
107
107
|
else
|
108
108
|
s = Score.parse(header)
|
109
109
|
error(400, 'The score is invalid') unless s.valid?
|
110
|
+
error(400, 'The score is expired') if s.expired?
|
110
111
|
error(400, 'The score is weak') if s.strength < Score::STRENGTH && !settings.opts['ignore-score-weakness']
|
111
112
|
return if s.value < Front::MIN_SCORE && !settings.opts['ignore-score-weakness']
|
112
113
|
if settings.address == "#{s.host}:#{s.port}" && !settings.opts['ignore-score-weakness']
|
@@ -130,6 +131,7 @@ while #{settings.address} is in '#{settings.opts['network']}'")
|
|
130
131
|
headers['Cache-Control'] = 'no-cache'
|
131
132
|
headers['X-Zold-Path'] = request.url
|
132
133
|
headers['X-Zold-Version'] = settings.opts['expose-version']
|
134
|
+
headers['X-Zold-Repo'] = Zold::REPO
|
133
135
|
headers[Http::PROTOCOL_HEADER] = settings.protocol.to_s
|
134
136
|
headers['Access-Control-Allow-Origin'] = '*'
|
135
137
|
headers[Http::SCORE_HEADER] = score.reduced(Front::MIN_SCORE).to_s
|
@@ -194,7 +196,7 @@ from #{request.ip} in #{Age.new(@start, limit: 1)}")
|
|
194
196
|
get '/' do
|
195
197
|
content_type('application/json')
|
196
198
|
pretty(
|
197
|
-
repo:
|
199
|
+
repo: Zold::REPO,
|
198
200
|
version: settings.opts['expose-version'],
|
199
201
|
alias: settings.node_alias,
|
200
202
|
network: settings.opts['network'],
|
data/lib/zold/remotes.rb
CHANGED
@@ -194,7 +194,7 @@ module Zold
|
|
194
194
|
list.each do |r|
|
195
195
|
pool.post do
|
196
196
|
Thread.current.abort_on_exception = true
|
197
|
-
Thread.current.name = "remotes-#{idx}@#{r[:host]}:#{r[:port]}"
|
197
|
+
Thread.current.name = "remotes-#{idx.value}@#{r[:host]}:#{r[:port]}"
|
198
198
|
start = Time.now
|
199
199
|
begin
|
200
200
|
yield Remotes::Remote.new(
|
data/lib/zold/version.rb
CHANGED
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.18.
|
4
|
+
version: 0.18.6
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Yegor Bugayenko
|
@@ -578,7 +578,6 @@ files:
|
|
578
578
|
- lib/zold/commands/remove.rb
|
579
579
|
- lib/zold/commands/routines/gc.rb
|
580
580
|
- lib/zold/commands/routines/reconnect.rb
|
581
|
-
- lib/zold/commands/routines/spread.rb
|
582
581
|
- lib/zold/commands/show.rb
|
583
582
|
- lib/zold/commands/taxes.rb
|
584
583
|
- lib/zold/commands/thread_badge.rb
|
@@ -628,7 +627,6 @@ files:
|
|
628
627
|
- resources/root.pub
|
629
628
|
- test/commands/routines/test_gc.rb
|
630
629
|
- test/commands/routines/test_reconnect.rb
|
631
|
-
- test/commands/routines/test_spread.rb
|
632
630
|
- test/commands/test_alias.rb
|
633
631
|
- test/commands/test_calculate.rb
|
634
632
|
- test/commands/test_clean.rb
|
@@ -703,7 +701,7 @@ licenses:
|
|
703
701
|
- MIT
|
704
702
|
metadata: {}
|
705
703
|
post_install_message: |-
|
706
|
-
Thanks for installing Zold 0.18.
|
704
|
+
Thanks for installing Zold 0.18.6!
|
707
705
|
Study our White Paper: https://papers.zold.io/wp.pdf
|
708
706
|
Read our blog posts: https://blog.zold.io
|
709
707
|
Try online wallet at: https://wts.zold.io
|
@@ -737,7 +735,6 @@ test_files:
|
|
737
735
|
- features/support/env.rb
|
738
736
|
- test/commands/routines/test_gc.rb
|
739
737
|
- test/commands/routines/test_reconnect.rb
|
740
|
-
- test/commands/routines/test_spread.rb
|
741
738
|
- test/commands/test_alias.rb
|
742
739
|
- test/commands/test_calculate.rb
|
743
740
|
- test/commands/test_clean.rb
|
@@ -1,62 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
# Copyright (c) 2018 Yegor Bugayenko
|
4
|
-
#
|
5
|
-
# Permission is hereby granted, free of charge, to any person obtaining a copy
|
6
|
-
# of this software and associated documentation files (the 'Software'), to deal
|
7
|
-
# in the Software without restriction, including without limitation the rights
|
8
|
-
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
9
|
-
# copies of the Software, and to permit persons to whom the Software is
|
10
|
-
# furnished to do so, subject to the following conditions:
|
11
|
-
#
|
12
|
-
# The above copyright notice and this permission notice shall be included in all
|
13
|
-
# copies or substantial portions of the Software.
|
14
|
-
#
|
15
|
-
# THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
16
|
-
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
17
|
-
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFINGEMENT. IN NO EVENT SHALL THE
|
18
|
-
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
19
|
-
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
20
|
-
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
21
|
-
# SOFTWARE.
|
22
|
-
|
23
|
-
require_relative '../../log'
|
24
|
-
require_relative '../../id'
|
25
|
-
require_relative '../push'
|
26
|
-
|
27
|
-
# Spread random wallets to the network.
|
28
|
-
# Author:: Yegor Bugayenko (yegor256@gmail.com)
|
29
|
-
# Copyright:: Copyright (c) 2018 Yegor Bugayenko
|
30
|
-
# License:: MIT
|
31
|
-
module Zold
|
32
|
-
# Routines module
|
33
|
-
module Routines
|
34
|
-
# Spread them
|
35
|
-
class Spread
|
36
|
-
def initialize(opts, wallets, remotes, log: Log::NULL)
|
37
|
-
@opts = opts
|
38
|
-
@wallets = wallets
|
39
|
-
@remotes = remotes
|
40
|
-
@log = log
|
41
|
-
end
|
42
|
-
|
43
|
-
def exec(_ = 0)
|
44
|
-
return if @remotes.all.empty?
|
45
|
-
if @opts['routine-immediately']
|
46
|
-
@log.info('Spreading the wallets immediately, because of --routine-immediately')
|
47
|
-
else
|
48
|
-
sleep(60)
|
49
|
-
end
|
50
|
-
ids = @wallets.all.sample(10)
|
51
|
-
Push.new(wallets: @wallets, remotes: @remotes, log: @log).run(
|
52
|
-
['push', "--network=#{@opts['network']}"] + ids.map(&:to_s)
|
53
|
-
)
|
54
|
-
if ids.empty?
|
55
|
-
@log.info("Spread didn't push any wallets, we are empty")
|
56
|
-
else
|
57
|
-
@log.info("Spread #{ids.count} random wallets out of #{@wallets.all.count}: #{ids.join(', ')}")
|
58
|
-
end
|
59
|
-
end
|
60
|
-
end
|
61
|
-
end
|
62
|
-
end
|
@@ -1,45 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
# Copyright (c) 2018 Yegor Bugayenko
|
4
|
-
#
|
5
|
-
# Permission is hereby granted, free of charge, to any person obtaining a copy
|
6
|
-
# of this software and associated documentation files (the 'Software'), to deal
|
7
|
-
# in the Software without restriction, including without limitation the rights
|
8
|
-
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
9
|
-
# copies of the Software, and to permit persons to whom the Software is
|
10
|
-
# furnished to do so, subject to the following conditions:
|
11
|
-
#
|
12
|
-
# The above copyright notice and this permission notice shall be included in all
|
13
|
-
# copies or substantial portions of the Software.
|
14
|
-
#
|
15
|
-
# THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
16
|
-
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
17
|
-
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFINGEMENT. IN NO EVENT SHALL THE
|
18
|
-
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
19
|
-
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
20
|
-
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
21
|
-
# SOFTWARE.
|
22
|
-
|
23
|
-
require 'minitest/autorun'
|
24
|
-
require 'webmock/minitest'
|
25
|
-
require_relative '../../test__helper'
|
26
|
-
require_relative '../../fake_home'
|
27
|
-
require_relative '../../node/fake_node'
|
28
|
-
require_relative '../../../lib/zold/commands/routines/spread.rb'
|
29
|
-
require_relative '../../../lib/zold/node/entrance.rb'
|
30
|
-
|
31
|
-
# Spread test.
|
32
|
-
# Author:: Yegor Bugayenko (yegor256@gmail.com)
|
33
|
-
# Copyright:: Copyright (c) 2018 Yegor Bugayenko
|
34
|
-
# License:: MIT
|
35
|
-
class TestSpread < Zold::Test
|
36
|
-
def test_spread_wallets
|
37
|
-
FakeHome.new(log: test_log).run do |home|
|
38
|
-
5.times { home.create_wallet }
|
39
|
-
opts = {
|
40
|
-
'routine-immediately' => true
|
41
|
-
}
|
42
|
-
Zold::Routines::Spread.new(opts, home.wallets, home.remotes, log: test_log).exec
|
43
|
-
end
|
44
|
-
end
|
45
|
-
end
|