zold 0.13.31 → 0.13.32

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: c98b1e9d02790f3993431a547adc638b53e7388e
4
- data.tar.gz: fda7df22416b00eebc03f9bcefaed0aa847c8a7a
3
+ metadata.gz: efe52b4e0be9a85e1a66d18a637d4495c6fd7409
4
+ data.tar.gz: e698b73bda8784b6eb40d3ca9d50b175050938da
5
5
  SHA512:
6
- metadata.gz: ff4a715122869803cef3bf0045badbf837d9e64a550dcd2b3f0690dad7ea30b31824f923cc53e2bd1c2ae3b38ece51b3a1e5a80ba8dae8bde7ade0c3af98a3b9
7
- data.tar.gz: 88c77327f5eeaf7a909c69bb5c85b9d10571491bf5503b1bf6d931bd8eafd336f2518d3320be404c1d4835dac2d71ef6731f94547cd1f3ac99eaa04505209dc8
6
+ metadata.gz: a1d4c2a547c39e6647cc44021edc81ade879816a09768f730823b143a287dec9b5fe69c6cdc34567d2afe8daa34975f0194d7511cde5ffb6b3f630d5071aa110
7
+ data.tar.gz: e87c42f314772d1b789cedfc629e0551a41c7e980a8804c9403c9e37256870f8b73fc347845edd184af80e59379fcfd01a5378d94d36ca2e14b173d79add425f
@@ -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.info("There are #{@remotes.all.count} remote nodes in the list")
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.info("There are #{@remotes.all.count} remote nodes in the list")
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']}) in #{(Time.now - start).round(2)}s")
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
@@ -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.debug("Transaction ##{txn.id} attempts to make the balance negative: #{txn.to_text}")
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.debug("Invalid RSA signature at transaction ##{txn.id} of #{wallet.id}: #{txn.to_text}")
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.debug("RSA signature is redundant at ##{txn.id} of #{wallet.id}: #{txn.to_text}")
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 = 20
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
@@ -23,5 +23,5 @@
23
23
  # Copyright:: Copyright (c) 2018 Yegor Bugayenko
24
24
  # License:: MIT
25
25
  module Zold
26
- VERSION = '0.13.31'.freeze
26
+ VERSION = '0.13.32'.freeze
27
27
  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.13.31
4
+ version: 0.13.32
5
5
  platform: ruby
6
6
  authors:
7
7
  - Yegor Bugayenko