define('BLOCK_SIZE', 100);
define('NONCE_INCREMENT', 0.0000000000000001);
define('START_TIME', microtime(TRUE));
+define('CHECK_POINT', 'chash.pos');
// Found hashes
$foundHashes = array();
$totalHashes = 0;
$totalBlocks = 0;
-// Create nonce (small)
-$nonce = 1 / mt_rand();
+// Is the check point there?
+if (is_readable(CHECK_POINT)) {
+ // Then load it
+ $checkPoint = file_get_contents(CHECK_POINT);
+ // Explode it
+ $data = explode(':', $checkPoint);
+
+ // 1st element is nonce, 2nd hash
+ $nonce = $data[0];
+ $modulaHash = $data[1];
+} else {
+ // Create nonce (small)
+ $nonce = 1 / mt_rand();
+}
+
+// Output again
+print ('modulaHash=' . $modulaHash . PHP_EOL);
+print ('nonce=' . $nonce . PHP_EOL);
+
+// Start "mining"
while (TRUE) {
// Init hash-per-block counter and hashrate
$hashesPerBlock = 0;
array_push($foundHashes, $nonceHash);
// Found hash:
- print ('FOUND: nonceHash=' . $nonceHash .',nonce=' . $nonce . ',iter=' . $iter . PHP_EOL);
+ print ('FOUND: nonceHash=' . $nonceHash . ',nonce=' . $nonce . ',iter=' . $iter . PHP_EOL);
+
+ // Write check-point
+ file_put_contents(CHECK_POINT, $nonce . ':' . $nonceHash);
// Use nonceHash as next modula hash
$modulaHash = $nonceHash;