From 54d651a3b4f8f299b0e0613e16623682b75f3773 Mon Sep 17 00:00:00 2001 From: ourlink Date: Sun, 2 Nov 2025 13:32:36 -0600 Subject: [PATCH 1/6] Update Utility.php Add new formatting routines for Diff and Hash --- src/Utility.php | 31 +++++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) diff --git a/src/Utility.php b/src/Utility.php index 1a107b1..6e6852a 100644 --- a/src/Utility.php +++ b/src/Utility.php @@ -216,6 +216,36 @@ function bytesToGb($size, int $round = 1){ return $size; } +function formatDiff($hashes, int $round = 1){ + // Define the units (H/s, KH/s, MH/s, GH/s, TH/s, PH/s, EH/s) + $units = array('', 'Kb', 'Mb', 'Gb', 'Tb', 'Pb', 'Eb'); + $i = 0; + + // Loop until the hashrate is less than 1000, incrementing the unit + while ($hashes >= 1000 && $i < count($units) - 1) { + $hashes /= 1000; + $i++; + } + + // Format the number with the specified precision and append the unit + return number_format($hashes, $round) . ' ' . $units[$i]; +} + +function formatHash($hashes, int $round = 1){ + // Define the units (H/s, KH/s, MH/s, GH/s, TH/s, PH/s, EH/s) + $units = array('H/s', 'KH/s', 'MH/s', 'GH/s', 'TH/s', 'PH/s', 'EH/s'); + $i = 0; + + // Loop until the hashrate is less than 1000, incrementing the unit + while ($hashes >= 1000 && $i < count($units) - 1) { + $hashes /= 1000; + $i++; + } + + // Format the number with the specified precision and append the unit + return number_format($hashes, $round) . ' ' . $units[$i]; +} + function getDateTime($timestamp){ $date = date("Y-m-d H:i:s",(int) $timestamp); return $date; @@ -721,3 +751,4 @@ function compare($a, $b) } ?> + From 90d8aa6dfdea5f72140bb49ce203eb6a13c40666 Mon Sep 17 00:00:00 2001 From: ourlink Date: Sun, 2 Nov 2025 13:35:31 -0600 Subject: [PATCH 2/6] Update Node.php Convert content to use new formatting routines. --- src/Node.php | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/Node.php b/src/Node.php index 76fbf8d..3849620 100644 --- a/src/Node.php +++ b/src/Node.php @@ -155,8 +155,10 @@ function __construct() { $blockInfo = $bitcoind->getblock($blockchainInfo["bestblockhash"]); $this->bHeightAgo = round((time()-checkInt($blockInfo["time"]))/60, 1); $this->bcSize = bytesToGb($blockchainInfo["size_on_disk"], 1); - $this->diff = checkInt($blockchainInfo["difficulty"]); - $this->hashRate = round(checkInt($miningInfo["networkhashps"])/1000000000000000000,3); + // $this->diff = checkInt($blockchainInfo["difficulty"]); + $this->diff = formatDiff($blockchainInfo["difficulty"], 2); + //$this->hashRate = round(checkInt($miningInfo["networkhashps"])/1000000000000000000,3); + $this->hashRate = formatHash($miningInfo["networkhashps"], 3); $this->mNetTime = getDateTime($blockchainInfo["mediantime"]); // Blockchain -> Soft forks if(isset($blockchainInfo["softforks"])) { @@ -166,3 +168,4 @@ function __construct() { } } } + From 67bd39a87ff6577c3b84953d8c59d05364fca0bd Mon Sep 17 00:00:00 2001 From: ourlink Date: Sun, 2 Nov 2025 13:36:50 -0600 Subject: [PATCH 3/6] Update main.phtml Remove HardCoded EH/s rate --- views/main.phtml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/views/main.phtml b/views/main.phtml index 74c4a86..c485f64 100644 --- a/views/main.phtml +++ b/views/main.phtml @@ -113,7 +113,7 @@ Chain chain ?> Size bcSize ?> GB Difficulty diff ?> - Hashrate hashRate ?> EH/s + Hashrate hashRate ?> Mediantime mNetTime ?> @@ -352,3 +352,4 @@ + From 8c0f3da833a0985992453f596f04b7f569312804 Mon Sep 17 00:00:00 2001 From: ourlink Date: Sun, 2 Nov 2025 13:50:26 -0600 Subject: [PATCH 4/6] Update Utility.php Cleanup comments. --- src/Utility.php | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/src/Utility.php b/src/Utility.php index 6e6852a..fc97b79 100644 --- a/src/Utility.php +++ b/src/Utility.php @@ -216,19 +216,19 @@ function bytesToGb($size, int $round = 1){ return $size; } -function formatDiff($hashes, int $round = 1){ - // Define the units (H/s, KH/s, MH/s, GH/s, TH/s, PH/s, EH/s) +function formatDiff($diff, int $round = 1){ + // Define the units ('', Kb, Mb, Gb, Tb, Pb, Eb) $units = array('', 'Kb', 'Mb', 'Gb', 'Tb', 'Pb', 'Eb'); $i = 0; // Loop until the hashrate is less than 1000, incrementing the unit - while ($hashes >= 1000 && $i < count($units) - 1) { - $hashes /= 1000; + while ($diff >= 1000 && $i < count($units) - 1) { + $diff /= 1000; $i++; } // Format the number with the specified precision and append the unit - return number_format($hashes, $round) . ' ' . $units[$i]; + return number_format($diff, $round) . ' ' . $units[$i]; } function formatHash($hashes, int $round = 1){ @@ -752,3 +752,4 @@ function compare($a, $b) ?> + From 3def15343aa3993852eeee21c67a7cdc854d88e3 Mon Sep 17 00:00:00 2001 From: ourlink Date: Sun, 2 Nov 2025 13:51:43 -0600 Subject: [PATCH 5/6] Update Node.php Cleanup comments. --- src/Node.php | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/Node.php b/src/Node.php index 3849620..5fb27e3 100644 --- a/src/Node.php +++ b/src/Node.php @@ -155,9 +155,7 @@ function __construct() { $blockInfo = $bitcoind->getblock($blockchainInfo["bestblockhash"]); $this->bHeightAgo = round((time()-checkInt($blockInfo["time"]))/60, 1); $this->bcSize = bytesToGb($blockchainInfo["size_on_disk"], 1); - // $this->diff = checkInt($blockchainInfo["difficulty"]); $this->diff = formatDiff($blockchainInfo["difficulty"], 2); - //$this->hashRate = round(checkInt($miningInfo["networkhashps"])/1000000000000000000,3); $this->hashRate = formatHash($miningInfo["networkhashps"], 3); $this->mNetTime = getDateTime($blockchainInfo["mediantime"]); // Blockchain -> Soft forks @@ -169,3 +167,4 @@ function __construct() { } } + From 02a20479111d4ce86188218e6387fbbe60d00ace Mon Sep 17 00:00:00 2001 From: ourlink Date: Sun, 2 Nov 2025 14:08:13 -0600 Subject: [PATCH 6/6] Update Utility.php Add ZH/s for hashrate. --- src/Utility.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/Utility.php b/src/Utility.php index fc97b79..31e613a 100644 --- a/src/Utility.php +++ b/src/Utility.php @@ -233,7 +233,7 @@ function formatDiff($diff, int $round = 1){ function formatHash($hashes, int $round = 1){ // Define the units (H/s, KH/s, MH/s, GH/s, TH/s, PH/s, EH/s) - $units = array('H/s', 'KH/s', 'MH/s', 'GH/s', 'TH/s', 'PH/s', 'EH/s'); + $units = array('H/s', 'KH/s', 'MH/s', 'GH/s', 'TH/s', 'PH/s', 'EH/s', 'ZH/s'); $i = 0; // Loop until the hashrate is less than 1000, incrementing the unit @@ -753,3 +753,4 @@ function compare($a, $b) ?> +