zold 0.13.31 → 0.13.32
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/lib/zold/commands/remote.rb +4 -3
- data/lib/zold/http.rb +2 -0
- data/lib/zold/metronome.rb +2 -1
- data/lib/zold/patch.rb +3 -3
- data/lib/zold/remotes.rb +8 -4
- data/lib/zold/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA1:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: efe52b4e0be9a85e1a66d18a637d4495c6fd7409
|
|
4
|
+
data.tar.gz: e698b73bda8784b6eb40d3ca9d50b175050938da
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: a1d4c2a547c39e6647cc44021edc81ade879816a09768f730823b143a287dec9b5fe69c6cdc34567d2afe8daa34975f0194d7511cde5ffb6b3f630d5071aa110
|
|
7
|
+
data.tar.gz: e87c42f314772d1b789cedfc629e0551a41c7e980a8804c9403c9e37256870f8b73fc347845edd184af80e59379fcfd01a5378d94d36ca2e14b173d79add425f
|
data/lib/zold/commands/remote.rb
CHANGED
|
@@ -132,7 +132,7 @@ Available options:"
|
|
|
132
132
|
@remotes.add(host, port)
|
|
133
133
|
@log.info("#{host}:#{port} added to the list, #{@remotes.all.count} total")
|
|
134
134
|
end
|
|
135
|
-
@log.
|
|
135
|
+
@log.debug("There are #{@remotes.all.count} remote nodes in the list")
|
|
136
136
|
end
|
|
137
137
|
|
|
138
138
|
def remove(host, port, opts)
|
|
@@ -143,7 +143,7 @@ Available options:"
|
|
|
143
143
|
raise "#{host}:#{port} is not in the list" unless opts['force']
|
|
144
144
|
@log.debug("#{host}:#{port} is not in the list")
|
|
145
145
|
end
|
|
146
|
-
@log.
|
|
146
|
+
@log.debug("There are #{@remotes.all.count} remote nodes in the list")
|
|
147
147
|
end
|
|
148
148
|
|
|
149
149
|
# Returns an array of Zold::Score
|
|
@@ -202,7 +202,8 @@ it's recommended to reboot, but I don't do it because of --never-reboot")
|
|
|
202
202
|
end
|
|
203
203
|
end
|
|
204
204
|
capacity << { host: score.host, port: score.port, count: json['all'].count }
|
|
205
|
-
@log.info("#{r}: #{Rainbow(score.value).green} (#{json['version']})
|
|
205
|
+
@log.info("#{r}: the score is #{Rainbow(score.value).green} (#{json['version']}) \
|
|
206
|
+
in #{(Time.now - start).round(2)}s")
|
|
206
207
|
end
|
|
207
208
|
max_capacity = capacity.map { |c| c[:count] }.max || 0
|
|
208
209
|
capacity.each do |c|
|
data/lib/zold/http.rb
CHANGED
|
@@ -52,6 +52,7 @@ module Zold
|
|
|
52
52
|
def get
|
|
53
53
|
http = Net::HTTP.new(@uri.host, @uri.port)
|
|
54
54
|
http.read_timeout = 5
|
|
55
|
+
http.open_timeout = 5
|
|
55
56
|
path = @uri.path
|
|
56
57
|
path += '?' + @uri.query if @uri.query
|
|
57
58
|
http.request_get(path, headers)
|
|
@@ -61,6 +62,7 @@ module Zold
|
|
|
61
62
|
|
|
62
63
|
def put(body)
|
|
63
64
|
http = Net::HTTP.new(@uri.host, @uri.port)
|
|
65
|
+
http.open_timeout = 5
|
|
64
66
|
http.read_timeout = 10
|
|
65
67
|
path = @uri.path
|
|
66
68
|
path += '?' + @uri.query if @uri.query
|
data/lib/zold/metronome.rb
CHANGED
|
@@ -43,7 +43,8 @@ module Zold
|
|
|
43
43
|
routine.exec(step)
|
|
44
44
|
end
|
|
45
45
|
step += 1
|
|
46
|
-
@log.info("Routine #{routine.class.name} ##{step} done in #{(Time.now - start).round(2)}s
|
|
46
|
+
@log.info("Routine #{routine.class.name} ##{step} done in #{(Time.now - start).round(2)}s: \
|
|
47
|
+
#{@threads.map { |t| "#{t.name}/#{t.status}" }.join(',')}")
|
|
47
48
|
sleep(1)
|
|
48
49
|
end
|
|
49
50
|
end
|
data/lib/zold/patch.rb
CHANGED
|
@@ -67,15 +67,15 @@ module Zold
|
|
|
67
67
|
next
|
|
68
68
|
end
|
|
69
69
|
if !@txns.empty? && @txns.map(&:amount).inject(&:+) < txn.amount
|
|
70
|
-
@log.
|
|
70
|
+
@log.error("Transaction ##{txn.id} attempts to make the balance negative: #{txn.to_text}")
|
|
71
71
|
next
|
|
72
72
|
end
|
|
73
73
|
unless Signature.new.valid?(@key, wallet.id, txn)
|
|
74
|
-
@log.
|
|
74
|
+
@log.error("Invalid RSA signature at transaction ##{txn.id} of #{wallet.id}: #{txn.to_text}")
|
|
75
75
|
next
|
|
76
76
|
end
|
|
77
77
|
elsif !txn.sign.nil? && !txn.sign.empty?
|
|
78
|
-
@log.
|
|
78
|
+
@log.error("RSA signature is redundant at ##{txn.id} of #{wallet.id}: #{txn.to_text}")
|
|
79
79
|
next
|
|
80
80
|
end
|
|
81
81
|
@log.debug("Merged on top: #{txn.to_text}")
|
data/lib/zold/remotes.rb
CHANGED
|
@@ -36,7 +36,7 @@ module Zold
|
|
|
36
36
|
PORT = 4096
|
|
37
37
|
|
|
38
38
|
# At what amount of errors we delete the remote automatically
|
|
39
|
-
TOLERANCE =
|
|
39
|
+
TOLERANCE = 8
|
|
40
40
|
|
|
41
41
|
# Empty, for standalone mode
|
|
42
42
|
class Empty
|
|
@@ -52,12 +52,14 @@ module Zold
|
|
|
52
52
|
# One remote.
|
|
53
53
|
class Remote
|
|
54
54
|
attr_reader :host, :port
|
|
55
|
-
def initialize(host, port, score, log: Log::Quiet.new)
|
|
55
|
+
def initialize(host, port, score, idx, log: Log::Quiet.new)
|
|
56
56
|
@host = host
|
|
57
57
|
raise 'Post must be Integer' unless port.is_a?(Integer)
|
|
58
58
|
@port = port
|
|
59
59
|
raise 'Score must be of type Score' unless score.is_a?(Score)
|
|
60
60
|
@score = score
|
|
61
|
+
raise 'Idx must be of type Integer' unless idx.is_a?(Integer)
|
|
62
|
+
@idx = idx
|
|
61
63
|
@log = log
|
|
62
64
|
end
|
|
63
65
|
|
|
@@ -66,7 +68,7 @@ module Zold
|
|
|
66
68
|
end
|
|
67
69
|
|
|
68
70
|
def to_s
|
|
69
|
-
"#{@host}:#{@port}"
|
|
71
|
+
"#{@host}:#{@port}/#{@idx}"
|
|
70
72
|
end
|
|
71
73
|
|
|
72
74
|
def assert_code(code, response)
|
|
@@ -161,9 +163,11 @@ module Zold
|
|
|
161
163
|
best = farm.best[0]
|
|
162
164
|
require_relative 'score'
|
|
163
165
|
score = best.nil? ? Score::ZERO : best
|
|
166
|
+
idx = 0
|
|
164
167
|
all.each do |r|
|
|
165
168
|
begin
|
|
166
|
-
yield Remotes::Remote.new(r[:host], r[:port], score, log: log)
|
|
169
|
+
yield Remotes::Remote.new(r[:host], r[:port], score, idx, log: log)
|
|
170
|
+
idx += 1
|
|
167
171
|
rescue StandardError => e
|
|
168
172
|
error(r[:host], r[:port])
|
|
169
173
|
errors = errors(r[:host], r[:port])
|
data/lib/zold/version.rb
CHANGED