zold 0.14.11 → 0.14.12

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: a2b8ac4c48c2e84846da60308cd5f19915bf4832
4
- data.tar.gz: e9f5d5362f6e95bd36370d04e5363fdeb0809a19
3
+ metadata.gz: eebbf694c3af2594b3ff82b988bfdc53a5c926f2
4
+ data.tar.gz: a10ed4895198184566d4495fa8ddc7a5d6fb42bb
5
5
  SHA512:
6
- metadata.gz: 17b505d402d6ed1a76848560ebea98989178c2704c676976eff4c82d3e44647e94d771ed15f428d2d604521772481c7fa4187183ba8058dd6be9355b6ea0c9ed
7
- data.tar.gz: 8126b35c3fafbb825047fa1fbc43450fc3f20d76dd85ef6ca6eccdb6b60bb16c176a52d14c9eedfed465bdf18d32449d6c6db70e6bfc315be167b9b05a34c9d0
6
+ metadata.gz: 2b064373631472b0ea87c017d662ba5886fc6a4258a60387431bc4cc71fd65b47de25c20f5aea3f3031680bc07d1c53d6ffd2de8523698be265794f8d96b5936
7
+ data.tar.gz: c39bd06b4edf7f3f520b7ed7732eb4130662354a0845897ac0087ac39684d9d8671da753d2bae087c68a4f02e5d158fa3c191ef67a4abf33e56caa57509bf5d6
@@ -49,7 +49,7 @@ until zold fetch 0000000000000000 --ignore-score-weakness; do
49
49
  if ((i==5)); then
50
50
  cat ${first}/log.txt
51
51
  echo "The wallet has not been distributed, after ${i} attempts"
52
- exit -1
52
+ exit 9
53
53
  fi
54
54
  sleep 1
55
55
  done
@@ -59,15 +59,15 @@ done
59
59
  json=$(curl --silent --show-error http://localhost:${first})
60
60
  if [ ! $(echo ${json} | jq -r '.entrance.queue') == "0" ]; then
61
61
  echo "The queue is not empty after PUSH, it's a bug"
62
- exit -1
62
+ exit 5
63
63
  fi
64
64
  if [ $(echo ${json} | jq -r '.entrance.history_size') == "0" ]; then
65
65
  echo "The history doesn't have a wallet, it's a bug"
66
- exit -1
66
+ exit 6
67
67
  fi
68
68
  if [ ! $(echo ${json} | jq -r '.wallets') == "1" ]; then
69
69
  echo "The wallet is not there for some reason, it's a bug"
70
- exit -1
70
+ exit 7
71
71
  fi
72
72
 
73
73
  # Now, we remove the wallet from the second node and expect the first
@@ -79,7 +79,7 @@ until zold fetch 0000000000000000 --ignore-score-weakness; do
79
79
  if ((i==5)); then
80
80
  cat ${first}/log.txt
81
81
  echo "The wallet has not been spread, after ${i} attempts"
82
- exit -1
82
+ exit 8
83
83
  fi
84
84
  sleep 1
85
85
  done
@@ -54,6 +54,7 @@ module Zold
54
54
  @routines.each do |r|
55
55
  @threads << Thread.start do
56
56
  Thread.current.name = r.class.name
57
+ Thread.current.priority = -100
57
58
  step = 0
58
59
  while alive
59
60
  start = Time.now
@@ -53,6 +53,7 @@ module Zold
53
53
  raise 'Network can\'t be nil' if network.nil?
54
54
  @network = network
55
55
  @history = []
56
+ @speed = []
56
57
  @mutex = Mutex.new
57
58
  end
58
59
 
@@ -63,7 +64,8 @@ module Zold
63
64
  def to_json
64
65
  {
65
66
  'history': @history.join(', '),
66
- 'history_size': @history.count
67
+ 'history_size': @history.count,
68
+ 'speed': @speed.empty? ? 0 : (@speed.inject(&:+) / @speed.count)
67
69
  }
68
70
  end
69
71
 
@@ -94,8 +96,10 @@ module Zold
94
96
  end
95
97
  @mutex.synchronize do
96
98
  @history.shift if @history.length > 16
99
+ @speed.shift if @speed.length > 64
97
100
  wallet = @wallets.find(id)
98
101
  @history << "#{id}/#{sec}/#{modified.count}/#{wallet.balance.to_zld}/#{wallet.txns.count}t"
102
+ @speed << sec
99
103
  end
100
104
  modified
101
105
  end
@@ -77,6 +77,7 @@ module Zold
77
77
  @threads = (1..threads).map do |t|
78
78
  Thread.new do
79
79
  Thread.current.name = "f#{t}"
80
+ Thread.current.priority = -100
80
81
  loop do
81
82
  VerboseThread.new(@log).run do
82
83
  cycle(host, port, strength, threads)
@@ -68,6 +68,7 @@ module Zold
68
68
  @modified = Queue.new
69
69
  @push = Thread.start do
70
70
  Thread.current.abort_on_exception = true
71
+ Thread.current.priority = -100
71
72
  Thread.current.name = 'push'
72
73
  VerboseThread.new(@log).run(true) do
73
74
  loop do
@@ -183,9 +183,11 @@ module Zold
183
183
  require_relative 'score'
184
184
  score = best.nil? ? Score::ZERO : best
185
185
  idx = 0
186
- pool = Concurrent::FixedThreadPool.new([all.count, Concurrent.processor_count * 16].min, max_queue: 0)
186
+ pool = Concurrent::FixedThreadPool.new([all.count, Concurrent.processor_count * 4].min, max_queue: 0)
187
187
  all.each do |r|
188
188
  pool.post do
189
+ Thread.current.name = 'remotes'
190
+ Thread.current.priority = -100
189
191
  start = Time.now
190
192
  begin
191
193
  yield Remotes::Remote.new(r[:host], r[:port], score, idx, log: log, network: @network)
@@ -25,6 +25,6 @@
25
25
  # Copyright:: Copyright (c) 2018 Yegor Bugayenko
26
26
  # License:: MIT
27
27
  module Zold
28
- VERSION = '0.14.11'
28
+ VERSION = '0.14.12'
29
29
  PROTOCOL = 2
30
30
  end
@@ -65,6 +65,7 @@ class TestEntrance < Minitest::Test
65
65
  e = Zold::Entrance.new(home.wallets, home.remotes, home.copies.root, 'x', log: test_log)
66
66
  e.push(wallet.id, File.read(wallet.path))
67
67
  assert(e.to_json[:history].include?(wallet.id.to_s))
68
+ assert(e.to_json[:speed].positive?)
68
69
  end
69
70
  end
70
71
  end
@@ -125,7 +125,7 @@ class TestCopies < Minitest::Test
125
125
  wallet = home.create_wallet(id)
126
126
  amount = Zold::Amount.new(zld: 1.99)
127
127
  key = Zold::Key.new(file: 'fixtures/id_rsa')
128
- wallet.sub(amount, "NOPREFIX@#{id}", key, text)
128
+ wallet.sub(amount, "NOPREFIX@#{id}", key, text, time: Time.parse('2018-01-01T01:01:01Z'))
129
129
  File.read(wallet.path)
130
130
  end
131
131
  end
@@ -40,15 +40,17 @@ class TestZold < Minitest::Test
40
40
  script = File.join(dir, f)
41
41
  File.write(script, File.read('fixtures/scripts/_head.sh') + File.read(File.join('fixtures/scripts', f)))
42
42
  bin = File.join(Dir.pwd, 'bin/zold')
43
+ out = []
43
44
  Dir.chdir(dir) do
44
45
  Open3.popen2e("/bin/bash #{f} #{bin} 2>&1") do |stdin, stdout, thr|
45
46
  stdin.close
46
47
  until stdout.eof?
47
48
  line = stdout.gets
48
49
  test_log.debug(line)
50
+ out << line
49
51
  end
50
52
  code = thr.value.to_i
51
- assert_equal(0, code, f)
53
+ assert_equal(0, code, f + out.join("\n"))
52
54
  end
53
55
  end
54
56
  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.14.11
4
+ version: 0.14.12
5
5
  platform: ruby
6
6
  authors:
7
7
  - Yegor Bugayenko