[IMPROVED] Added some block stats to Pool Statistics
This commit is contained in:
parent
c6dd4086ff
commit
03aef00367
@ -52,6 +52,64 @@ 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) {
|
||||
$this->debug->append("STA " . __METHOD__, 4);
|
||||
if ($data = $this->memcache->get(__FUNCTION__ . $aTimeFrame)) return $data;
|
||||
$date = new DateTime();
|
||||
$actualTime = $date->getTimestamp();
|
||||
$aTimeDiff = $actualTime - $aTimeFrame;
|
||||
$stmt = $this->mysqli->prepare("
|
||||
SELECT COUNT(id) AS count FROM " . $this->block->getTableName() . "
|
||||
WHERE 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);
|
||||
$this->debug->append("Failed to get Blocks by time: ". $this->mysqli->error);
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Get our last $limit blocks found
|
||||
* @param limit int Last limit blocks
|
||||
|
||||
@ -42,7 +42,25 @@ 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);
|
||||
|
||||
// Propagate content our template
|
||||
|
||||
$smarty->assign("FOUNDLASTHOUR", $iFoundLastHour);
|
||||
$smarty->assign("FOUNDLAST24HOURS", $iFoundLastDay);
|
||||
$smarty->assign("FOUNDLAST7DAYS", $iFoundLastWeek);
|
||||
$smarty->assign("FOUNDLAST4WEEKS", $iFoundLastMonth);
|
||||
|
||||
$smarty->assign("BLOCKSTATSVALID", $iFoundValidBlock);
|
||||
$smarty->assign("BLOCKSTATSORPHAN", $iFoundOrphanBlock);
|
||||
|
||||
$smarty->assign("ESTTIME", $iEstTime);
|
||||
$smarty->assign("ESTTIME", $iEstTime);
|
||||
$smarty->assign("TIMESINCELAST", $dTimeSinceLast);
|
||||
$smarty->assign("BLOCKSFOUND", $aBlocksFoundData);
|
||||
|
||||
@ -50,8 +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>
|
||||
</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>
|
||||
<td class="leftheader">Time Since Last Block</td>
|
||||
<td>{$TIMESINCELAST|seconds_to_words}</td>
|
||||
</tr>
|
||||
|
||||
@ -40,8 +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>
|
||||
</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>
|
||||
<td class="leftheader">Time Since Last Block</td>
|
||||
<td>{$TIMESINCELAST|seconds_to_words}</td>
|
||||
</tr>
|
||||
|
||||
@ -1,4 +1,4 @@
|
||||
<article class="module width_half">
|
||||
<article class="module width_half">
|
||||
<header><h3>General Statistics</h3></header>
|
||||
<div class="module_content">
|
||||
<table width="100%">
|
||||
@ -46,6 +46,26 @@
|
||||
<th align="left">Est. Shares this Round</td>
|
||||
<td id="b-target"></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>
|
||||
<th align="left">Time Since Last Block</td>
|
||||
<td>{$TIMESINCELAST|seconds_to_words}</td>
|
||||
|
||||
Loading…
Reference in New Issue
Block a user