Exemplo n.º 1
0
    def benchmark(self):
        cmd = self._get_run_cmd(self.path_to_exec,
                                self.algo,
                                "",
                                "",
                                "",
                                "",
                                kwargs={
                                    "--benchmark": "",
                                    "--no-color": ""
                                })
        LOG.debug("Benchmarking \033[92m%s\033[0m...", self.algo)
        cache_key = "BENCHHR%s" % (cmd)
        cached_benchmark = MinerStore.get(cache_key)
        if cached_benchmark:
            b = Rate(cached_benchmark)
            LOG.debug("Benchmark found in cache: %s!", b)
            return b

        LOG.info("Benchmark not found for \033[92m%s\033[0m. Benchmarking...",
                 self.algo)

        bench_proc = start_proc(cmd, pipe_stdout=True)
        bm = Benchmarker()

        for line in bench_proc.stdout:
            line = line.strip().decode("UTF-8")

            if "Total:" in line:
                r = Rate(line.split(":")[-1].strip())
                bm.add_rate(r)

                final_hashrate = bm.get_benchmark()
                if final_hashrate:
                    break

        term_proc(bench_proc)

        MinerStore.set(cache_key, str(final_hashrate))
        LOG.info("Benchmark found: %s!", final_hashrate)

        return final_hashrate
Exemplo n.º 2
0
    def mine(mining_group):
        LOG.info("Starting miner for \033[92m%s\033[0m!", mining_group)
        current_miner = None

        while True:
            LOG.debug("Finding most profitable miner for \033[92m%s\033[0m...",
                      mining_group)
            best_miner = mining_group.get_most_profitable_miner()
            LOG.debug("Found best miner: \033[92m%s\033[0m!", best_miner)

            if best_miner != current_miner:
                LOG.info("Switching to \033[92m%s\033[0m...", best_miner)
                MiningMonitor.switch_miner_and_return_when_started(
                    best_miner, current_miner)
                current_miner = best_miner
                LOG.info("Switch complete! Shares incoming...")

            MiningMonitor._check_file_descriptors()
            MiningMonitor._wait(current_miner)