From ead3efbdd94a0f2a00d315fb955c39f92811b0a5 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Roland=20H=C3=A4der?= Date: Mon, 28 Apr 2014 14:53:25 +0200 Subject: [PATCH] Added check-point file. MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit Signed-off-by: Roland Häder --- contrib/chash/chash.php | 28 +++++++++++++++++++++++++--- 1 file changed, 25 insertions(+), 3 deletions(-) diff --git a/contrib/chash/chash.php b/contrib/chash/chash.php index 6705b960..1059641f 100644 --- a/contrib/chash/chash.php +++ b/contrib/chash/chash.php @@ -5,6 +5,7 @@ define('HASH_ALGO', MHASH_RIPEMD320); define('BLOCK_SIZE', 100); define('NONCE_INCREMENT', 0.0000000000000001); define('START_TIME', microtime(TRUE)); +define('CHECK_POINT', 'chash.pos'); // Found hashes $foundHashes = array(); @@ -240,9 +241,27 @@ $totalReward = 0; $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; @@ -322,7 +341,10 @@ while (TRUE) { 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; -- 2.30.2