$nonce = 1 / mt_rand();
while (TRUE) {
- // Init hash-per-block counter
+ // Init hash-per-block counter and hashrate
$hashesPerBlock = 0;
+ $hashrate = 0;
// Wait for BLOCK_SIZE iterations (= found hashes). This is one block
$timeBlock = microtime(TRUE);
//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 / BLOCK_SIZE * 1000;
print ('timeBlock=' . $timeBlock . ',timeBadHashes=' . $timeBadHashes . ',hashesPerBlock=' . $hashesPerBlock .',reward=' . $reward . PHP_EOL);
$totalBlocks++;
$hashesPerBlock = 0;
- // Calculate next hash from both hashes
- $modulaHash = doubleHashString(modulaHash($nonceHash, $modulaHash));
+ // Use nonceHash as next modula hash
+ $modulaHash = $nonceHash;
// Calculate new nonce
$nonce = calculateNonce($nonce);