zold 0.13.18 → 0.13.19
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/node/farm.rb +18 -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: 95dd6bbdccf72324cc861ebb29f6825d23bce93c
|
4
|
+
data.tar.gz: b34a5fb43a224631fda4f53b87e8ca8216253c2b
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 28f4bb01e0856b74017923a941373df4098883e94c6e2c1cd72ae061cfb26a7985ad012095874878663663460e0ddc6b738ec4d6cc0575c0a610cb70805f9b94
|
7
|
+
data.tar.gz: 67bdc25fd68c191257169d29b7d12e1bc1c1b56becff6385e6470784c572c72ef2e07eb12bd42a7d9aa5b787fce8536d914bc0b0f9a70159094df688e8b4e019
|
data/lib/zold/node/farm.rb
CHANGED
@@ -73,7 +73,16 @@ module Zold
|
|
73
73
|
end
|
74
74
|
end
|
75
75
|
end
|
76
|
-
@
|
76
|
+
@threads << Thread.new do
|
77
|
+
VerboseThread.new(@log).run do
|
78
|
+
Thread.current.name = 'farm-cleaner'
|
79
|
+
loop do
|
80
|
+
sleep(60)
|
81
|
+
clean(host, port, strength, threads)
|
82
|
+
end
|
83
|
+
end
|
84
|
+
end
|
85
|
+
@log.info("Farm started with #{@threads.count} threads at #{host}:#{port}, strength is #{strength}")
|
77
86
|
return unless block_given?
|
78
87
|
begin
|
79
88
|
yield
|
@@ -95,12 +104,17 @@ module Zold
|
|
95
104
|
|
96
105
|
private
|
97
106
|
|
98
|
-
def
|
99
|
-
if @scores.length < threads
|
107
|
+
def clean(host, port, strength, threads)
|
108
|
+
if @scores.length < threads || @best.count < threads
|
100
109
|
zero = Score.new(Time.now, host, port, @invoice, strength: strength)
|
101
110
|
@scores << zero
|
102
111
|
@best << zero
|
103
112
|
end
|
113
|
+
@best = @best.reject(&:expired?).sort_by(&:value).reverse.take(threads)
|
114
|
+
end
|
115
|
+
|
116
|
+
def cycle(host, port, strength, threads)
|
117
|
+
clean(host, port, strength, threads)
|
104
118
|
s = @scores.pop
|
105
119
|
return unless s.valid?
|
106
120
|
return unless s.host == host
|
@@ -112,7 +126,7 @@ module Zold
|
|
112
126
|
save(n)
|
113
127
|
@best << n
|
114
128
|
after = @best.map(&:value).max
|
115
|
-
|
129
|
+
clean(host, port, strength, threads)
|
116
130
|
@log.debug("#{Thread.current.name}: best score is #{@best[0]}") if before != after && !after.zero?
|
117
131
|
end
|
118
132
|
@scores << n
|
data/lib/zold/version.rb
CHANGED