From d6831f8cd303201fdc04a1eff9554d126096bfeb Mon Sep 17 00:00:00 2001 From: Roland Haeder Date: Sun, 30 Mar 2014 00:17:48 +0100 Subject: [PATCH 1/1] Added a lot stuff + initial "block miner". MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit Signed-off-by: Roland Häder --- contrib/chash/chash.php | 159 +++++++++++++++++++++++++++++++++++++++- 1 file changed, 157 insertions(+), 2 deletions(-) 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] ?> -- 2.30.2