X-Git-Url: https://git.mxchange.org/?p=core.git;a=blobdiff_plain;f=contrib%2Fchash%2Fchash.php;h=d41a45ba213a2cbd755410665b568e7466a14eb5;hp=a1e91c28c568cc741185092e906a2af57598c1fb;hb=fc622548d23d4de88af69dffbdf04ac29ef05f82;hpb=b4683952aea678cf8e45d95989176073961de136 diff --git a/contrib/chash/chash.php b/contrib/chash/chash.php index a1e91c28..d41a45ba 100644 --- a/contrib/chash/chash.php +++ b/contrib/chash/chash.php @@ -1,6 +1,11 @@ = 1) { + // Calculate hashrate/sec + $timeHash = abs(microtime(TRUE) - $timeHash); + $hashrate = 1 / $timeHash * $iter * 2 + 2; + print ('hashesPerBlock=' . $hashesPerBlock . ',hashrate=' . $hashrate . ' hashes/sec.' . PHP_EOL); + + // Reset timer + $timeDisplay = microtime(TRUE); + } // END - if + + // Found hash: + //print ('nonceHash=' . $nonceHash .',iter=' . $iter . PHP_EOL); + } // END - while + + // Time taken for one block + $timeBlock = abs(microtime(TRUE) - $timeBlock); + //print ('calculateSumFromHash(modulaHash)=' . calculateSumFromHash($modulaHash) . PHP_EOL); + //print ('calculateSumFromHash(nonceHash)=' . calculateSumFromHash($nonceHash) . PHP_EOL); + + // Is the hash rate unset? + if ($hashrate == 0) { + // Then calculate it again + $hashrate = 1 / $timeBlock * $iter * 2 + 2; + } // END - if + + // Calculate reward + $reward = abs($timeBlock - $timeBadHashes) / $hashrate * $hashesPerBlock / getBlockSize() * 1000; + print ('timeBlock=' . $timeBlock . ',timeBadHashes=' . $timeBadHashes . ',hashesPerBlock=' . $hashesPerBlock .',reward=' . $reward . PHP_EOL); + + // Block completed + $totalHashes += $hashesPerBlock; + $totalBlocks++; + $hashesPerBlock = 0; + + // Use nonceHash as next modula hash + $modulaHash = $nonceHash; + + // Add reward to total + $totalReward += $reward; + + // Calculate average block value + $blockValue = $totalReward / $totalBlocks * $totalHashes / (getBlockSize() * $totalBlocks); + + // Calculate reward per hour (= 3600 seconds) + $rewardPerHour = $totalReward / abs(microtime(TRUE) - START_TIME) * 3600; + + print ('totalReward=' . $totalReward . ',blockValue=' . $blockValue . ',rewardPerHour=' . $rewardPerHour . PHP_EOL); +} // END - while + // [EOF] ?>