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 +4 -4
- data/fixtures/scripts/distribute-wallet.sh +5 -5
- data/lib/zold/metronome.rb +1 -0
- data/lib/zold/node/entrance.rb +5 -1
- data/lib/zold/node/farm.rb +1 -0
- data/lib/zold/node/spread_entrance.rb +1 -0
- data/lib/zold/remotes.rb +3 -1
- data/lib/zold/version.rb +1 -1
- data/test/node/test_entrance.rb +1 -0
- data/test/test_copies.rb +1 -1
- data/test/test_zold.rb +3 -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: eebbf694c3af2594b3ff82b988bfdc53a5c926f2
|
4
|
+
data.tar.gz: a10ed4895198184566d4495fa8ddc7a5d6fb42bb
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
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
|
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
|
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
|
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
|
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
|
82
|
+
exit 8
|
83
83
|
fi
|
84
84
|
sleep 1
|
85
85
|
done
|
data/lib/zold/metronome.rb
CHANGED
data/lib/zold/node/entrance.rb
CHANGED
@@ -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
|
data/lib/zold/node/farm.rb
CHANGED
data/lib/zold/remotes.rb
CHANGED
@@ -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 *
|
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)
|
data/lib/zold/version.rb
CHANGED
data/test/node/test_entrance.rb
CHANGED
@@ -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
|
data/test/test_copies.rb
CHANGED
@@ -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
|
data/test/test_zold.rb
CHANGED
@@ -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
|