lib/zold/commands/remote.rb
def elect(opts)
      scores = []
      @remotes.iterate(@log, farm: @farm, threads: opts['threads']) do |r|
        uri = '/'
        res = r.http(uri).get
        r.assert_code(200, res)
        json = JsonPage.new(res.body, uri).to_hash
        score = Score.parse_json(json['score'])
        r.assert_valid_score(score)
        r.assert_score_ownership(score)
        r.assert_score_strength(score) unless opts['ignore-score-weakness']
        r.assert_score_value(score, opts['min-score']) unless opts['ignore-score-value']
        if r.master? && opts['--ignore-masters']
          @log.debug("#{r} ignored, it's a master node")
          next
        end
        scores << score
      end
      scores = scores.sample(opts['max-winners'])
      if scores.empty?
        @log.info("No winners elected out of #{@remotes.all.count} remotes")
      else
        scores.each { |s| @log.info("Elected: #{s.reduced(4)}") }
      end
      scores.sort_by(&:value).reverse
    end
def elect(opts)
      scores = []
      @remotes.iterate(@log, farm: @farm, threads: opts['threads']) do |r|
        uri = '/'
        res = r.http(uri).get
        r.assert_code(200, res)
        json = JsonPage.new(res.body, uri).to_hash
        score = Score.parse_json(json['score'])
        r.assert_valid_score(score)
        r.assert_score_ownership(score)
        r.assert_score_strength(score) unless opts['ignore-score-weakness']
        r.assert_score_value(score, opts['min-score']) unless opts['ignore-score-value']
        if r.master? && opts['--ignore-masters']
          @log.debug("#{r} ignored, it's a master node")
          next
        end
        scores << score
      end
      scores = scores.sample(opts['max-winners'])
      if scores.empty?
        @log.info("No winners elected out of #{@remotes.all.count} remotes")
      else
        scores.each { |s| @log.info("Elected: #{s.reduced(4)}") }
      end
      scores.sort_by(&:value).reverse
    end
Returns an array of Zold::Score