lib/zold/node/farm.rb in zold-0.13.28 vs lib/zold/node/farm.rb in zold-0.13.29

- old
+ new

@@ -115,12 +115,17 @@ def cleanup(host, port, strength, threads) scores = load before = scores.map(&:value).max.to_i save(threads, [Score.new(Time.now, host, port, @invoice, strength: strength)]) scores = load - @pipeline << scores.max_by(&:age) if @pipeline.size.zero? + push(scores) after = scores.map(&:value).max.to_i @log.debug("#{Thread.current.name}: best score is #{scores[0]}") if before != after && !after.zero? + end + + def push(scores) + free = scores.reject { |s| @threads.find { |t| t.name == s.to_mnemo } } + @pipeline << free[0] if @pipeline.size.zero? && !free.empty? end def cycle(host, port, strength, threads) s = @pipeline.pop return unless s.valid?