Removed hashesPerBlock display + reduced blocked size as it is now much harder to...
[core.git] / contrib / chash / chash.php
index 6dc0eff3dc0002334bd72029155aef13ab4a445e..3ba7e162290e11879bf8d1f4101f50b15303f031 100644 (file)
@@ -2,8 +2,8 @@
 error_reporting(E_ALL | E_STRICT);
 
 define('HASH_ALGO', MHASH_RIPEMD320);
-define('BLOCK_SIZE', 1000);
-define('NONCE_INCREMENT', 0.00001);
+define('BLOCK_SIZE', 100);
+define('NONCE_INCREMENT', 0.0000000001);
 define('START_TIME', microtime(TRUE));
 
 /**
@@ -262,6 +262,7 @@ while (TRUE) {
 
                // Init counter
                $iter = 0;
+               $iterSecond = 0;
 
                // Now start the "mining" ...
                $timeHash = microtime(TRUE);
@@ -274,34 +275,32 @@ while (TRUE) {
 
                        // Calculate sums
                        $sumNonce  = calculateSumFromHash($nonceHash);
-                       //print('hashesPerBlock=' . $hashesPerBlock . PHP_EOL);
 
                        // Time spend in loop
                        $testTime = abs(microtime(TRUE) - $timeDisplay);
 
                        // Calculate hashrate/sec
-                       $hashrate = 1 / $testTime * $iter * 2 + 2;
+                       $hashrate = 1 / $testTime * $iterSecond * 2;
 
                        // Only every second
                        if ($testTime >= 1) {
                                // Display hash rate
-                               print ('hashesPerBlock=' . $hashesPerBlock . ',hashrate=' . $hashrate . ' hashes/sec.' . PHP_EOL);
+                               print ('hashrate=' . $hashrate . ' hashes/sec.' . PHP_EOL);
 
                                // Reset timer
                                $timeDisplay = microtime(TRUE);
+                               $iterSecond  = 0;
                        } // END - if
 
                        // Next round
                        $iter++;
+                       $iterSecond++;
                        //print ('nonce=' . $nonce . ',iter=' . $iter . PHP_EOL);
                        //print ('nonceHash=' . $nonceHash . PHP_EOL);
                        //print ('sumNonce=' . $sumNonce . PHP_EOL);
                        //print ('sumModula=' . $sumModula . PHP_EOL);
                } // END - while
 
-               // Add amount of hashes to block (double-hash)
-               $hashesPerBlock += $iter * 2 + 2;
-
                // If the iteration is zero, then no hash is found
                if ($iter == 0) {
                        // Bad block found
@@ -315,8 +314,11 @@ while (TRUE) {
                        continue;
                } // END - if
 
+               // Add amount of hashes to block (double-hash)
+               $hashesPerBlock += $iter * 2 + 2;
+
                // Found hash:
-               //print ('nonceHash=' . $nonceHash .',iter=' . $iter . PHP_EOL);
+               print ('FOUND: nonceHash=' . $nonceHash .',iter=' . $iter . PHP_EOL);
 
                // Use nonceHash as next modula hash
                $modulaHash = $nonceHash;