Пример #1
0
    def get_best_miner_for_algorithm(self, algorithm, supported_miners=[]):
        calibration_data = Calibration().get_hashrates(self)

        best_hashrate = 0
        best_miner = None

        if calibration_data:
            for miner_name in calibration_data.keys():
                if algorithm in calibration_data[miner_name].keys(
                ) and calibration_data[miner_name][algorithm][
                        "hashrate"] > best_hashrate:
                    if Miners().enabled(miner_name) and Miners().is_up(
                            miner_name):
                        if supported_miners == [] or miner_name in supported_miners:
                            best_hashrate = calibration_data[miner_name][
                                algorithm]["hashrate"]
                            best_miner = miner_name

        return best_miner
Пример #2
0
    def check_hashrate(self):
        hashrates = Calibration().get_hashrates(self)

        if len(self.algos) == 0:
            return

        miner = self.algos[0]['miner']
        algo = self.algos[0]['algo']

        if not miner in hashrates.keys() or not algo in hashrates[miner].keys(
        ):
            self.log(
                'warning', 'running uncalibrated algorithm %s with miner %s' %
                (algo, miner))
            return

        if self.algos[0]['algo'] in Config().get('algorithms.single'):
            baseline = float(hashrates[miner][algo]['hashrate'])
        else:
            baseline = float(hashrates[miner][algo]['hashrate'][0])

        threshold_pc_value = (
            baseline / 100) * Config().get('hashrate_alert_threshold_percent')

        hr_s = Units().hashrate_str(self.algos[0]['hashrate'][0])
        bl_s = Units().hashrate_str(baseline)

        if self.algos[0]['hashrate'][0] < baseline and (
                baseline - self.algos[0]['hashrate'][0]) >= threshold_pc_value:
            self.log(
                'warning', 'hashrate %d%% below calibrated rate [%s < %s]' %
                (Config().get('hashrate_alert_threshold_percent'), hr_s, bl_s))

        if self.algos[0]['hashrate'][0] > baseline and (
                self.algos[0]['hashrate'][0] - baseline) >= threshold_pc_value:
            self.log(
                'warning', 'hashrate %d%% above calibrated rate [%s > %s]' %
                (Config().get('hashrate_alert_threshold_percent'), hr_s, bl_s))