From: Roland Haeder Date: Sat, 29 Mar 2014 23:17:48 +0000 (+0100) Subject: Added a lot stuff + initial "block miner". X-Git-Url: https://git.mxchange.org/?a=commitdiff_plain;h=d6831f8cd303201fdc04a1eff9554d126096bfeb;p=core.git Added a lot stuff + initial "block miner". Signed-off-by: Roland Häder --- diff --git a/contrib/chash/chash.php b/contrib/chash/chash.php index 5bd2893d..7101f3dc 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); + + // Calculate reward + $reward = abs($timeBlock - $timeBadHashes) / $hashrate * $hashesPerBlock / BLOCK_SIZE * 1000; + print ('timeBlock=' . $timeBlock . ',timeBadHashes=' . $timeBadHashes . ',hashesPerBlock=' . $hashesPerBlock .',reward=' . $reward . PHP_EOL); + + // Block completed + $totalHashes += $hashesPerBlock; + $totalBlocks++; + $hashesPerBlock = 0; + + // Calculate next hash from both hashes + $modulaHash = doubleHashString(modulaHash($nonceHash, $modulaHash)); + + // Calculate new nonce + $nonce = calculateNonce($nonce); + + // Add reward to total + $totalReward += $reward; + + // Calculate average block value + $blockValue = $totalReward / $totalBlocks * $totalHashes / (BLOCK_SIZE * $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] ?>