target_bits; } /** * Read our coin value precision **/ public function getCoinValuePrevision() { return $this->coin_value_precision; } /** * Read our share difficulty precision **/ public function getShareDifficultyPrecision() { return $this->share_difficulty_precision; } /** * Calculate the PPS value for this coin * WARNING: Get this wrong and you will over- or underpay your miners! **/ public function calcPPSValue($pps_reward, $dDifficulty) { return ($pps_reward / (pow(2, $this->target_bits) * $dDifficulty)); } /** * Calculate our hashrate based on shares inserted to DB * We use diff1 share values, not a baseline one **/ public function calcHashrate($shares, $interval) { return $shares * pow(2, $this->target_bits) / $interval / 1000; } /** * Calculate estimated shares of this coin, this is using baseline * according to our configuration difficulty **/ public function calcEstaimtedShares($dDifficulty) { return (float)round(pow(2, (32 - $this->target_bits)) * $dDifficulty, $this->share_difficulty_precision); } /** * Calculate our networks expected time per block **/ public function calcNetworkExpectedTimePerBlock($dDifficulty, $dNetworkHashrate) { if ($dNetworkHashrate > 0) { return pow(2, 32) * $dDifficulty / $dNetworkHashrate; } else { return 0; } } /** * Calculate next expected difficulty based on current difficulty **/ public function calcExpectedNextDifficulty($dDifficulty, $dNetworkHashrate) { $iExpectedTimePerBlock = $this->calcNetworkExpectedTimePerBlock($dDifficulty, $dNetworkHashrate); if (!empty($iExpectedTimePerBlock) && $iExpectedTimePerBlock > 0) { return round($dDifficulty * $this->config['cointarget'] / $iExpectedTimePerBlock, 8); } else { return 0; } } }