Signed-off-by: Roland Häder <roland@mxchange.org>
define('HASH_ALGO', MHASH_RIPEMD320);
define('BLOCK_SIZE', 1000);
define('HASH_ALGO', MHASH_RIPEMD320);
define('BLOCK_SIZE', 1000);
-define('NONCE_INCREMENT', 0.1);
+define('NONCE_INCREMENT', 1.0);
define('START_TIME', microtime(TRUE));
/**
define('START_TIME', microtime(TRUE));
/**
+/**
+ * Calculates current block
+ *
+ * @return $blockSize Block size
+ * @todo This needs improvement
+ */
+function getBlockSize () {
+ // For now only a constant block size
+ return BLOCK_SIZE;
+}
+
/*
* 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
/*
* 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
// Time waited for a good block again (no iteration)
$timeBadHashes = 0;
// Time waited for a good block again (no iteration)
$timeBadHashes = 0;
- while ($hashesPerBlock <= BLOCK_SIZE) {
+ while ($hashesPerBlock <= getBlockSize()) {
// Init counter
$iter = 0;
// Init counter
$iter = 0;
} // END - if
// Calculate reward
} // END - if
// Calculate reward
- $reward = abs($timeBlock - $timeBadHashes) / $hashrate * $hashesPerBlock / BLOCK_SIZE * 1000;
+ $reward = abs($timeBlock - $timeBadHashes) / $hashrate * $hashesPerBlock / getBlockSize() * 1000;
print ('timeBlock=' . $timeBlock . ',timeBadHashes=' . $timeBadHashes . ',hashesPerBlock=' . $hashesPerBlock .',reward=' . $reward . PHP_EOL);
// Block completed
print ('timeBlock=' . $timeBlock . ',timeBadHashes=' . $timeBadHashes . ',hashesPerBlock=' . $hashesPerBlock .',reward=' . $reward . PHP_EOL);
// Block completed
// Use nonceHash as next modula hash
$modulaHash = $nonceHash;
// Use nonceHash as next modula hash
$modulaHash = $nonceHash;
- // Calculate new nonce
- $nonce = calculateNonce($nonce);
-
// Add reward to total
$totalReward += $reward;
// Calculate average block value
// Add reward to total
$totalReward += $reward;
// Calculate average block value
- $blockValue = $totalReward / $totalBlocks * $totalHashes / (BLOCK_SIZE * $totalBlocks);
+ $blockValue = $totalReward / $totalBlocks * $totalHashes / (getBlockSize() * $totalBlocks);
// Calculate reward per hour (= 3600 seconds)
$rewardPerHour = $totalReward / abs(microtime(TRUE) - START_TIME) * 3600;
// Calculate reward per hour (= 3600 seconds)
$rewardPerHour = $totalReward / abs(microtime(TRUE) - START_TIME) * 3600;