[IMPROVED] Added Found/Valid/Orphaned to Stats
This commit is contained in:
parent
03aef00367
commit
b0f4edbc13
@ -52,59 +52,53 @@ class Statistics {
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Fetch last found orphaned / valid
|
||||
**/
|
||||
function getBlockCountStatistics($aSearch) {
|
||||
$this->debug->append("STA " . __METHOD__, 4);
|
||||
if ($data = $this->memcache->get(__FUNCTION__ . $aSearch)) return $data;
|
||||
|
||||
if ($aSearch == 1)
|
||||
{
|
||||
$stmt = $this->mysqli->prepare("
|
||||
SELECT COUNT(id) AS count FROM " . $this->block->getTableName() . "
|
||||
WHERE confirmations > 0
|
||||
");
|
||||
} else {
|
||||
$stmt = $this->mysqli->prepare("
|
||||
SELECT COUNT(id) AS count FROM " . $this->block->getTableName() . "
|
||||
WHERE confirmations = -1
|
||||
");
|
||||
}
|
||||
if ($this->checkStmt($stmt) && $stmt->execute() && $result = $stmt->get_result())
|
||||
if ($aSearch == 1) return $this->memcache->setCache(BLOCKSTATSVALID, $result->fetch_object()->count);
|
||||
if ($aSearch == 0) return $this->memcache->setCache(BLOCKSTATSORPHAN, $result->fetch_object()->count);
|
||||
$this->debug->append("Failed to get Blocks by time: ". $this->mysqli->error);
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Fetch last found blocks by time
|
||||
**/
|
||||
function getLastFoundBlocksbyTime($aTimeFrame) {
|
||||
function getLastValidBlocksbyTime($aTimeFrame) {
|
||||
$this->debug->append("STA " . __METHOD__, 4);
|
||||
if ($data = $this->memcache->get(__FUNCTION__ . $aTimeFrame)) return $data;
|
||||
$date = new DateTime();
|
||||
$actualTime = $date->getTimestamp();
|
||||
$aTimeDiff = $actualTime - $aTimeFrame;
|
||||
if ($aTimeFrame == 0) $aTimeDiff = 0;
|
||||
$stmt = $this->mysqli->prepare("
|
||||
SELECT COUNT(id) AS count FROM " . $this->block->getTableName() . "
|
||||
WHERE time > ?
|
||||
WHERE confirmations > 0
|
||||
AND time >= ?
|
||||
");
|
||||
|
||||
if ($this->checkStmt($stmt) && $stmt->bind_param('i', $aTimeDiff) && $stmt->execute() && $result = $stmt->get_result())
|
||||
if ($aTimeFrame == 3600) return $this->memcache->setCache(FOUNDLASTHOUR, $result->fetch_object()->count);
|
||||
if ($aTimeFrame == 86400) return $this->memcache->setCache(FOUNDLAST24HOURS, $result->fetch_object()->count);
|
||||
if ($aTimeFrame == 604800) return $this->memcache->setCache(FOUNDLAST7DAYS, $result->fetch_object()->count);
|
||||
if ($aTimeFrame == 2419200) return $this->memcache->setCache(FOUNDLAST4WEEKS, $result->fetch_object()->count);
|
||||
if ($aTimeFrame == 0) return $this->memcache->setCache(FOUNDALLVALID, $result->fetch_object()->count);
|
||||
if ($aTimeFrame == 3600) return $this->memcache->setCache(FOUNDLASTHOURVALID, $result->fetch_object()->count);
|
||||
if ($aTimeFrame == 86400) return $this->memcache->setCache(FOUNDLAST24HOURSVALID, $result->fetch_object()->count);
|
||||
if ($aTimeFrame == 604800) return $this->memcache->setCache(FOUNDLAST7DAYSVALID, $result->fetch_object()->count);
|
||||
if ($aTimeFrame == 2419200) return $this->memcache->setCache(FOUNDLAST4WEEKSVALID, $result->fetch_object()->count);
|
||||
$this->debug->append("Failed to get Blocks by time: ". $this->mysqli->error);
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
|
||||
function getLastOrphanBlocksbyTime($aTimeFrame) {
|
||||
$this->debug->append("STA " . __METHOD__, 4);
|
||||
if ($data = $this->memcache->get(__FUNCTION__ . $aTimeFrame)) return $data;
|
||||
$date = new DateTime();
|
||||
$actualTime = $date->getTimestamp();
|
||||
$aTimeDiff = $actualTime - $aTimeFrame;
|
||||
if ($aTimeFrame == 0) $aTimeDiff = 0;
|
||||
$stmt = $this->mysqli->prepare("
|
||||
SELECT COUNT(id) AS count FROM " . $this->block->getTableName() . "
|
||||
WHERE confirmations = -1
|
||||
AND time >= ?
|
||||
");
|
||||
|
||||
if ($this->checkStmt($stmt) && $stmt->bind_param('i', $aTimeDiff) && $stmt->execute() && $result = $stmt->get_result())
|
||||
if ($aTimeFrame == 0) return $this->memcache->setCache(FOUNDALLORPHAN, $result->fetch_object()->count);
|
||||
if ($aTimeFrame == 3600) return $this->memcache->setCache(FOUNDLASTHOURORPHAN, $result->fetch_object()->count);
|
||||
if ($aTimeFrame == 86400) return $this->memcache->setCache(FOUNDLAST24HOURSORPHAN, $result->fetch_object()->count);
|
||||
if ($aTimeFrame == 604800) return $this->memcache->setCache(FOUNDLAST7DAYSORPHAN, $result->fetch_object()->count);
|
||||
if ($aTimeFrame == 2419200) return $this->memcache->setCache(FOUNDLAST4WEEKSORPHAN, $result->fetch_object()->count);
|
||||
$this->debug->append("Failed to get Blocks by time: ". $this->mysqli->error);
|
||||
return false;
|
||||
}
|
||||
|
||||
@ -42,23 +42,33 @@ if (!$smarty->isCached('master.tpl', $smarty_cache_key)) {
|
||||
$dTimeSinceLast = 0;
|
||||
}
|
||||
|
||||
$iFoundLastHour = $statistics->getLastFoundBlocksbyTime(3600);
|
||||
$iFoundLastDay = $statistics->getLastFoundBlocksbyTime(86400);
|
||||
$iFoundLastWeek = $statistics->getLastFoundBlocksbyTime(604800);
|
||||
$iFoundLastMonth = $statistics->getLastFoundBlocksbyTime(2419200);
|
||||
|
||||
$iFoundValidBlock = $statistics->getBlockCountStatistics(1);
|
||||
$iFoundOrphanBlock = $statistics->getBlockCountStatistics(0);
|
||||
|
||||
|
||||
$iFoundLastValid = $statistics->getLastValidBlocksbyTime(0);
|
||||
$iFoundLastHourValid = $statistics->getLastValidBlocksbyTime(3600);
|
||||
$iFoundLastDayValid = $statistics->getLastValidBlocksbyTime(86400);
|
||||
$iFoundLastWeekValid = $statistics->getLastValidBlocksbyTime(604800);
|
||||
$iFoundLastMonthValid = $statistics->getLastValidBlocksbyTime(2419200);
|
||||
|
||||
$iFoundLastOrphan = $statistics->getLastOrphanBlocksbyTime(0);
|
||||
$iFoundLastHourOrphan = $statistics->getLastOrphanBlocksbyTime(3600);
|
||||
$iFoundLastDayOrphan = $statistics->getLastOrphanBlocksbyTime(86400);
|
||||
$iFoundLastWeekOrphan = $statistics->getLastOrphanBlocksbyTime(604800);
|
||||
$iFoundLastMonthOrphan = $statistics->getLastOrphanBlocksbyTime(2419200);
|
||||
|
||||
|
||||
// Propagate content our template
|
||||
|
||||
$smarty->assign("FOUNDLASTHOUR", $iFoundLastHour);
|
||||
$smarty->assign("FOUNDLAST24HOURS", $iFoundLastDay);
|
||||
$smarty->assign("FOUNDLAST7DAYS", $iFoundLastWeek);
|
||||
$smarty->assign("FOUNDLAST4WEEKS", $iFoundLastMonth);
|
||||
$smarty->assign("FOUNDALLVALID", $iFoundLastValid);
|
||||
$smarty->assign("FOUNDLASTHOURVALID", $iFoundLastHourValid);
|
||||
$smarty->assign("FOUNDLAST24HOURSVALID", $iFoundLastDayValid);
|
||||
$smarty->assign("FOUNDLAST7DAYSVALID", $iFoundLastWeekValid);
|
||||
$smarty->assign("FOUNDLAST4WEEKSVALID", $iFoundLastMonthValid);
|
||||
|
||||
$smarty->assign("BLOCKSTATSVALID", $iFoundValidBlock);
|
||||
$smarty->assign("BLOCKSTATSORPHAN", $iFoundOrphanBlock);
|
||||
$smarty->assign("FOUNDALLORPHAN", $iFoundLastOrphan);
|
||||
$smarty->assign("FOUNDLASTHOURORPHAN", $iFoundLastHourOrphan);
|
||||
$smarty->assign("FOUNDLAST24HOURSORPHAN", $iFoundLastDayOrphan);
|
||||
$smarty->assign("FOUNDLAST7DAYSORPHAN", $iFoundLastWeekOrphan);
|
||||
$smarty->assign("FOUNDLAST4WEEKSORPHAN", $iFoundLastMonthOrphan);
|
||||
|
||||
$smarty->assign("ESTTIME", $iEstTime);
|
||||
$smarty->assign("ESTTIME", $iEstTime);
|
||||
|
||||
@ -50,28 +50,28 @@
|
||||
<td class="leftheader">Est. Shares this Round</td>
|
||||
{assign var=estshares value=(65536 * $DIFFICULTY) / pow(2, ($GLOBAL.config.targetdiff - 16))}
|
||||
<td>{$estshares|number_format:"0"} <font size="1">(done: {(100 / $estshares * $GLOBAL.roundshares.valid)|number_format:"2"} %)</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th align="left">Found / Valid / Orphan</td>
|
||||
<td>{$BLOCKSTATSVALID + $BLOCKSTATSORPHAN} / {$BLOCKSTATSVALID} / {$BLOCKSTATSORPHAN}</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th align="left">Blocks found last hour</td>
|
||||
<td>{$FOUNDLASTHOUR}</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th align="left">Blocks found last 24 hours</td>
|
||||
<td>{$FOUNDLAST24HOURS}</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th align="left">Blocks found last 7 days</td>
|
||||
<td>{$FOUNDLAST7DAYS}</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th align="left">Blocks found last 4 weeks</td>
|
||||
<td>{$FOUNDLAST4WEEKS}</td>
|
||||
</tr>
|
||||
<tr>
|
||||
</tr>
|
||||
<tr>
|
||||
<th align="left">All Blocks - Found / Valid / Orphan</td>
|
||||
<td>{$FOUNDALLVALID + $FOUNDALLORPHAN} / {$FOUNDALLVALID} / {$FOUNDALLORPHAN}</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th align="left">Blocks last hour - Found / Valid / Orphan</td>
|
||||
<td>{$FOUNDLASTHOURVALID + $FOUNDLASTHOURORPHAN} / {$FOUNDLASTHOURVALID} / {$FOUNDLASTHOURORPHAN}</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th align="left">Blocks last 24 hours - Found / Valid / Orphan</td>
|
||||
<td>{$FOUNDLAST24HOURSVALID + $FOUNDLAST24HOURSORPHAN} / {$FOUNDLAST24HOURSVALID} / {$FOUNDLAST24HOURSORPHAN}</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th align="left">Blocks last 7 days - Found / Valid / Orphan</td>
|
||||
<td>{$FOUNDLAST7DAYSVALID + $FOUNDLAST7DAYSORPHAN} / {$FOUNDLAST7DAYSVALID} / {$FOUNDLAST7DAYSORPHAN}</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th align="left">Blocks last 4 weeks - Found / Valid / Orphan</td>
|
||||
<td>{$FOUNDLAST4WEEKSVALID + $FOUNDLAST4WEEKSORPHAN} / {$FOUNDLAST4WEEKSVALID} / {$FOUNDLAST4WEEKSORPHAN}</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td class="leftheader">Time Since Last Block</td>
|
||||
<td>{$TIMESINCELAST|seconds_to_words}</td>
|
||||
</tr>
|
||||
|
||||
@ -40,28 +40,28 @@
|
||||
<tr>
|
||||
<td class="leftheader">Est. Shares this Round</td>
|
||||
<td>{((65536 * $DIFFICULTY) / pow(2, ($GLOBAL.config.targetdiff - 16)))|number_format:"0"} <font size="1">(done: {(100 / ((65536 * $DIFFICULTY) / pow(2, ($GLOBAL.config.targetdiff - 16))) * $GLOBAL.roundshares.valid)|number_format:"2"} %)</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th align="left">Found / Valid / Orphan</td>
|
||||
<td>{$BLOCKSTATSVALID + $BLOCKSTATSORPHAN} / {$BLOCKSTATSVALID} / {$BLOCKSTATSORPHAN}</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th align="left">Blocks found last hour</td>
|
||||
<td>{$FOUNDLASTHOUR}</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th align="left">Blocks found last 24 hours</td>
|
||||
<td>{$FOUNDLAST24HOURS}</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th align="left">Blocks found last 7 days</td>
|
||||
<td>{$FOUNDLAST7DAYS}</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th align="left">Blocks found last 4 weeks</td>
|
||||
<td>{$FOUNDLAST4WEEKS}</td>
|
||||
</tr>
|
||||
<tr>
|
||||
</tr>
|
||||
<tr>
|
||||
<th align="left">All Blocks - Found / Valid / Orphan</td>
|
||||
<td>{$FOUNDALLVALID + $FOUNDALLORPHAN} / {$FOUNDALLVALID} / {$FOUNDALLORPHAN}</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th align="left">Blocks last hour - Found / Valid / Orphan</td>
|
||||
<td>{$FOUNDLASTHOURVALID + $FOUNDLASTHOURORPHAN} / {$FOUNDLASTHOURVALID} / {$FOUNDLASTHOURORPHAN}</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th align="left">Blocks last 24 hours - Found / Valid / Orphan</td>
|
||||
<td>{$FOUNDLAST24HOURSVALID + $FOUNDLAST24HOURSORPHAN} / {$FOUNDLAST24HOURSVALID} / {$FOUNDLAST24HOURSORPHAN}</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th align="left">Blocks last 7 days - Found / Valid / Orphan</td>
|
||||
<td>{$FOUNDLAST7DAYSVALID + $FOUNDLAST7DAYSORPHAN} / {$FOUNDLAST7DAYSVALID} / {$FOUNDLAST7DAYSORPHAN}</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th align="left">Blocks last 4 weeks - Found / Valid / Orphan</td>
|
||||
<td>{$FOUNDLAST4WEEKSVALID + $FOUNDLAST4WEEKSORPHAN} / {$FOUNDLAST4WEEKSVALID} / {$FOUNDLAST4WEEKSORPHAN}</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td class="leftheader">Time Since Last Block</td>
|
||||
<td>{$TIMESINCELAST|seconds_to_words}</td>
|
||||
</tr>
|
||||
|
||||
@ -4,7 +4,7 @@
|
||||
<table width="100%">
|
||||
<tbody>
|
||||
<tr>
|
||||
<th align="left" width="30%">Pool Hash Rate</th>
|
||||
<th align="left" width="50%">Pool Hash Rate</th>
|
||||
<td width="70%"><span id="b-hashrate"></span> {$GLOBAL.hashunits.pool}</td>
|
||||
</tr>
|
||||
<tr>
|
||||
@ -15,21 +15,6 @@
|
||||
<th align="left">Current Active Workers</td>
|
||||
<td id="b-workers"></td>
|
||||
</tr>
|
||||
{if ! $GLOBAL.website.blockexplorer.disabled}
|
||||
<tr>
|
||||
<th align="left">Next Network Block</td>
|
||||
<td>{$CURRENTBLOCK + 1} <font size="1"> (Current: <a href="{$GLOBAL.website.blockexplorer.url}{$CURRENTBLOCKHASH}" target="_new">{$CURRENTBLOCK})</a></font></td>
|
||||
</tr>
|
||||
{else}
|
||||
<tr>
|
||||
<th align="left">Next Network Block</td>
|
||||
<td>{$CURRENTBLOCK + 1} (Current: {$CURRENTBLOCK})</td>
|
||||
</tr>
|
||||
{/if}
|
||||
<tr>
|
||||
<th align="left">Last Block Found</td>
|
||||
<td><a href="{$smarty.server.PHP_SELF}?page=statistics&action=round&height={$LASTBLOCK}" target="_new">{$LASTBLOCK|default:"0"}</a></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th align="left">Current Difficulty</td>
|
||||
{if ! $GLOBAL.website.chaininfo.disabled}
|
||||
@ -46,25 +31,49 @@
|
||||
<th align="left">Est. Shares this Round</td>
|
||||
<td id="b-target"></td>
|
||||
</tr>
|
||||
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
|
||||
<header><h3>Block Statistics</h3></header>
|
||||
<div class="module_content">
|
||||
<table width="100%">
|
||||
<tbody>
|
||||
{if ! $GLOBAL.website.blockexplorer.disabled}
|
||||
<tr>
|
||||
<th align="left">Found / Valid / Orphan</td>
|
||||
<td>{$BLOCKSTATSVALID + $BLOCKSTATSORPHAN} / {$BLOCKSTATSVALID} / {$BLOCKSTATSORPHAN}</td>
|
||||
<th align="left" width="50%">Next Network Block</td>
|
||||
<td>{$CURRENTBLOCK + 1} <font size="1"> (Current: <a href="{$GLOBAL.website.blockexplorer.url}{$CURRENTBLOCKHASH}" target="_new">{$CURRENTBLOCK})</a></font></td>
|
||||
</tr>
|
||||
{else}
|
||||
<tr>
|
||||
<th align="left">Next Network Block</td>
|
||||
<td>{$CURRENTBLOCK + 1} (Current: {$CURRENTBLOCK})</td>
|
||||
</tr>
|
||||
{/if}
|
||||
<tr>
|
||||
<th align="left">Last Block Found</td>
|
||||
<td><a href="{$smarty.server.PHP_SELF}?page=statistics&action=round&height={$LASTBLOCK}" target="_new">{$LASTBLOCK|default:"0"}</a></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th align="left">Blocks found last hour</td>
|
||||
<td>{$FOUNDLASTHOUR}</td>
|
||||
<th align="left">All Blocks - Found / Valid / Orphan</td>
|
||||
<td>{$FOUNDALLVALID + $FOUNDALLORPHAN} / {$FOUNDALLVALID} / {$FOUNDALLORPHAN}</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th align="left">Blocks found last 24 hours</td>
|
||||
<td>{$FOUNDLAST24HOURS}</td>
|
||||
<th align="left">Blocks last hour - Found / Valid / Orphan</td>
|
||||
<td>{$FOUNDLASTHOURVALID + $FOUNDLASTHOURORPHAN} / {$FOUNDLASTHOURVALID} / {$FOUNDLASTHOURORPHAN}</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th align="left">Blocks found last 7 days</td>
|
||||
<td>{$FOUNDLAST7DAYS}</td>
|
||||
<th align="left">Blocks last 24 hours - Found / Valid / Orphan</td>
|
||||
<td>{$FOUNDLAST24HOURSVALID + $FOUNDLAST24HOURSORPHAN} / {$FOUNDLAST24HOURSVALID} / {$FOUNDLAST24HOURSORPHAN}</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th align="left">Blocks found last 4 weeks</td>
|
||||
<td>{$FOUNDLAST4WEEKS}</td>
|
||||
<th align="left">Blocks last 7 days - Found / Valid / Orphan</td>
|
||||
<td>{$FOUNDLAST7DAYSVALID + $FOUNDLAST7DAYSORPHAN} / {$FOUNDLAST7DAYSVALID} / {$FOUNDLAST7DAYSORPHAN}</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th align="left">Blocks last 4 weeks - Found / Valid / Orphan</td>
|
||||
<td>{$FOUNDLAST4WEEKSVALID + $FOUNDLAST4WEEKSORPHAN} / {$FOUNDLAST4WEEKSVALID} / {$FOUNDLAST4WEEKSORPHAN}</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th align="left">Time Since Last Block</td>
|
||||
@ -72,6 +81,8 @@
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
|
||||
|
||||
</div>
|
||||
<footer>
|
||||
{if !$GLOBAL.website.api.disabled}<ul><li>These stats are also available in JSON format <a href="{$smarty.server.PHP_SELF}?page=api&action=getpoolstatus&api_key={$GLOBAL.userdata.api_key|default:""}">HERE</a></li></ul>{/if}
|
||||
|
||||
Loading…
Reference in New Issue
Block a user