lib/zold/node/farm.rb in zold-0.13.23 vs lib/zold/node/farm.rb in zold-0.13.24

- old
+ new

@@ -119,11 +119,11 @@ save([Score.new(Time.now, host, port, @invoice, strength: strength)]) else save end scores = load - @pipeline << scores.min_by(&:age) if @pipeline.size < threads + @pipeline << scores.min_by(&:age) if @pipeline.size.zero? after = scores.map(&:value).max.to_i @log.debug("#{Thread.current.name}: best score is #{scores[0]}") if before != after && !after.zero? end def cycle(host, port, strength, threads) @@ -140,26 +140,23 @@ scores = load + list @mutex.synchronize do AtomicFile.new(@cache).write( scores.select(&:valid?) .reject(&:expired?) + .sort_by(&:value) + .reverse + .uniq(&:time) .map(&:to_s) .uniq .join("\n") ) end end def load @mutex.synchronize do if File.exist?(@cache) - AtomicFile.new(@cache).read - .split(/\n/) - .map { |t| Score.parse(t) } - .select(&:valid?) - .reject(&:expired?) - .sort_by(&:value) - .reverse + AtomicFile.new(@cache).read.split(/\n/).map { |t| Score.parse(t) } else [] end end end