// Found hashes
$foundHashes = array();
+// Time when last flush occured
+global $timeFlush;
+
/**
* Continued-hashing
*
return $newNonce;
}
+/**
+ * Writes/flushes check-point file
+ *
+ * @return void
+ */
+function flushCheckPointFile ($nonce, $modulaHash, array $foundHashes) {
+ global $timeFlush;
+
+ // Display message
+ print ('FLUSHING: ' . count($foundHashes) . ' total found.' . PHP_EOL);
+
+ // Flush data
+ file_put_contents(CHECK_POINT, base64_encode($nonce) . ':' . $modulaHash . ':' . base64_encode(serialize($foundHashes)));
+
+ // Set time
+ $timeFlush = microtime(TRUE);
+}
+
/*
* Calculate "genesis" hashes, please note that these "genesis strings" are now
* known to the public as you can read them here in source code and therefore I
// Only once per 10 seconds
if ($testTime >= 10) {
- // Display message
- print ('FLUSHING: ' . count($foundHashes) . ' total found.' . PHP_EOL);
-
- // Write check-point
- file_put_contents(CHECK_POINT, base64_encode($nonce) . ':' . $modulaHash . ':' . base64_encode(serialize($foundHashes)));
-
- $timeFlush = microtime(TRUE);
+ // Flush check-point file
+ flushCheckPointFile($nonce, $modulaHash, $foundHashes);
} // END - if
// Next round
// Found hash:
print ('FOUND: nonceHash=' . $nonceHash . ',nonce=' . $nonce . ',iter=' . $iter . PHP_EOL);
+ // Flush check-point file after new hash is found
+ flushCheckPointFile($nonce, $nonceHash, $foundHashes);
// Use nonceHash as next modula hash
$modulaHash = $nonceHash;