diff --git a/public/include/classes/statistics.class.php b/public/include/classes/statistics.class.php index 02b3f204..fcb72531 100644 --- a/public/include/classes/statistics.class.php +++ b/public/include/classes/statistics.class.php @@ -22,6 +22,22 @@ class Statistics extends Base { return $this->getcache; } + /** + * Get our first block found + * + **/ + public function getFirstBlockFound() { + $this->debug->append("STA " . __METHOD__, 4); + if ($data = $this->memcache->get(__FUNCTION__)) return $data; + $stmt = $this->mysqli->prepare(" + SELECT + time FROM " . $this->block->getTableName() . " + ORDER BY id ASC LIMIT 1"); + if ($this->checkStmt($stmt) && $stmt->execute() && $result = $stmt->get_result()) + return $result->fetch_object()->time; + return false; + } + /** * Fetch last found blocks by time **/ @@ -44,7 +60,10 @@ class Statistics extends Base { IFNULL(SUM(IF(confirmations = -1 AND FROM_UNIXTIME(time) >= DATE_SUB(now(), INTERVAL 604800 SECOND), 1, 0)), 0) AS 7DaysOrphan, IFNULL(SUM(IF(FROM_UNIXTIME(time) >= DATE_SUB(now(), INTERVAL 2419200 SECOND), 1, 0)), 0) AS 4WeeksTotal, IFNULL(SUM(IF(confirmations > 0 AND FROM_UNIXTIME(time) >= DATE_SUB(now(), INTERVAL 2419200 SECOND), 1, 0)), 0) AS 4WeeksValid, - IFNULL(SUM(IF(confirmations = -1 AND FROM_UNIXTIME(time) >= DATE_SUB(now(), INTERVAL 2419200 SECOND), 1, 0)), 0) AS 4WeeksOrphan + IFNULL(SUM(IF(confirmations = -1 AND FROM_UNIXTIME(time) >= DATE_SUB(now(), INTERVAL 2419200 SECOND), 1, 0)), 0) AS 4WeeksOrphan, + IFNULL(SUM(IF(FROM_UNIXTIME(time) >= DATE_SUB(now(), INTERVAL 29030400 SECOND), 1, 0)), 0) AS 12MonthTotal, + IFNULL(SUM(IF(confirmations > 0 AND FROM_UNIXTIME(time) >= DATE_SUB(now(), INTERVAL 29030400 SECOND), 1, 0)), 0) AS 12MonthValid, + IFNULL(SUM(IF(confirmations = -1 AND FROM_UNIXTIME(time) >= DATE_SUB(now(), INTERVAL 29030400 SECOND), 1, 0)), 0) AS 12MonthOrphan FROM " . $this->block->getTableName()); if ($this->checkStmt($stmt) && $stmt->execute() && $result = $stmt->get_result()) return $this->memcache->setCache(__FUNCTION__, $result->fetch_assoc()); diff --git a/public/include/config/global.inc.dist.php b/public/include/config/global.inc.dist.php index 4a139582..b6814772 100644 --- a/public/include/config/global.inc.dist.php +++ b/public/include/config/global.inc.dist.php @@ -152,6 +152,20 @@ $config['accounts']['invitations']['count'] = 5; // Currency system used in this pool, default: `LTC` $config['currency'] = 'LTC'; +/** + * Coin Target in seconds + * + * Explanation + * Target time for coins to be generated + * + * Fastcoin: 12 seconds + * Litecoin: 2,5 minutes = 150 seconds + * Feathercoin: 2,5 minutes = 150 seconds + * Bitcoin: 10 minutes = 600 seconds + * + **/ +$config['cointarget'] = '150'; + /** * Default transaction fee to apply to user transactions * diff --git a/public/include/pages/statistics/blocks.inc.php b/public/include/pages/statistics/blocks.inc.php index d77663b4..cf812792 100644 --- a/public/include/pages/statistics/blocks.inc.php +++ b/public/include/pages/statistics/blocks.inc.php @@ -71,11 +71,14 @@ if (!$smarty->isCached('master.tpl', $smarty_cache_key)) { $iHours = 24; $aPoolStatistics = $statistics->getPoolStatsHours($iHours); - + $iFirstBlockFound = $statistics->getFirstBlockFound(); + $iTimeSinceFirstBlockFound = (time() - $iFirstBlockFound); + // Past blocks found, max 4 weeks back $iFoundBlocksByTime = $statistics->getLastBlocksbyTime(); - // Propagate content our template + $smarty->assign("FIRSTBLOCKFOUND", $iTimeSinceFirstBlockFound); + $smarty->assign("COINGENTIME", $config['cointarget']); $smarty->assign("LASTBLOCKSBYTIME", $iFoundBlocksByTime); $smarty->assign("BLOCKSFOUND", $aBlocksFoundData); $smarty->assign("BLOCKLIMIT", $iLimit); diff --git a/public/include/pages/statistics/pool.inc.php b/public/include/pages/statistics/pool.inc.php index c53a0c05..0252f1fb 100644 --- a/public/include/pages/statistics/pool.inc.php +++ b/public/include/pages/statistics/pool.inc.php @@ -44,8 +44,11 @@ if (!$smarty->isCached('master.tpl', $smarty_cache_key)) { // Past blocks found, max 4 weeks back $iFoundBlocksByTime = $statistics->getLastBlocksbyTime(); + $iFirstBlockFound = $statistics->getFirstBlockFound(); + $iTimeSinceFirstBlockFound = ($now->getTimestamp() - $iFirstBlockFound); // Propagate content our template + $smarty->assign("FIRSTBLOCKFOUND", $iTimeSinceFirstBlockFound); $smarty->assign("LASTBLOCKSBYTIME", $iFoundBlocksByTime); $smarty->assign("ESTTIME", $iEstTime); $smarty->assign("TIMESINCELAST", $dTimeSinceLast); diff --git a/public/templates/mmcFE/statistics/blocks/block_overview_time.tpl b/public/templates/mmcFE/statistics/blocks/block_overview_time.tpl new file mode 100644 index 00000000..b91ee837 --- /dev/null +++ b/public/templates/mmcFE/statistics/blocks/block_overview_time.tpl @@ -0,0 +1,64 @@ +{include file="global/block_header.tpl" BLOCK_HEADER="Block Shares" BLOCK_STYLE="clear:none;"} + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Gen Est.FoundValidOrphanRate Est.
All Time + {($FIRSTBLOCKFOUND / $COINGENTIME|default:"150")|number_format:"0"}{$LASTBLOCKSBYTIME.Total}{$LASTBLOCKSBYTIME.TotalValid}{$LASTBLOCKSBYTIME.TotalOrphan}{($LASTBLOCKSBYTIME.Total|default:"0.00" / ($FIRSTBLOCKFOUND / $COINGENTIME|default:"150") * 100)|number_format:"2"} %
Last Hour + {(3600 / $COINGENTIME|default:"150")}{$LASTBLOCKSBYTIME.1HourTotal}{$LASTBLOCKSBYTIME.1HourValid}{$LASTBLOCKSBYTIME.1HourOrphan}{($LASTBLOCKSBYTIME.1HourTotal|default:"0.00" / (3600 / $COINGENTIME|default:"150") * 100)|number_format:"2"} %
Last 24 Hours + {(86400 / $COINGENTIME|default:"150")}{$LASTBLOCKSBYTIME.24HourTotal}{$LASTBLOCKSBYTIME.24HourValid}{$LASTBLOCKSBYTIME.24HourOrphan}{($LASTBLOCKSBYTIME.24HourTotal|default:"0.00" / (86400 / $COINGENTIME|default:"150") * 100)|number_format:"2"} %
Last 7 Days + {(604800 / $COINGENTIME|default:"150")}{$LASTBLOCKSBYTIME.7DaysTotal}{$LASTBLOCKSBYTIME.7DaysValid}{$LASTBLOCKSBYTIME.7DaysOrphan}{($LASTBLOCKSBYTIME.7DaysTotal|default:"0.00" / (604800 / $COINGENTIME|default:"150") * 100)|number_format:"2"} %
Last 4 Weeks + {(2419200 / $COINGENTIME|default:"150")}{$LASTBLOCKSBYTIME.4WeeksTotal}{$LASTBLOCKSBYTIME.4WeeksValid}{$LASTBLOCKSBYTIME.4WeeksOrphan}{($LASTBLOCKSBYTIME.4WeeksTotal|default:"0.00" / (2419200 / $COINGENTIME|default:"150") * 100)|number_format:"2"} %
Last 12 Month + {(29030400 / $COINGENTIME|default:"150")}{$LASTBLOCKSBYTIME.12MonthTotal}{$LASTBLOCKSBYTIME.12MonthValid}{$LASTBLOCKSBYTIME.12MonthOrphan}{($LASTBLOCKSBYTIME.12MonthTotal|default:"0.00" / (29030400 / $COINGENTIME|default:"150") * 100)|number_format:"2"} %
+{include file="global/block_footer.tpl"} \ No newline at end of file diff --git a/public/templates/mmcFE/statistics/blocks/block_shares_graph.tpl b/public/templates/mmcFE/statistics/blocks/block_shares_graph.tpl new file mode 100644 index 00000000..4f161b38 --- /dev/null +++ b/public/templates/mmcFE/statistics/blocks/block_shares_graph.tpl @@ -0,0 +1,58 @@ +{include file="global/block_header.tpl" BLOCK_HEADER="Block Shares" BLOCK_STYLE="clear:none;"} +
+ + + + +{section block $BLOCKSFOUND step=-1} + +{/section} + + + + + +{section block $BLOCKSFOUND step=-1} + +{/section} + + + +{section block $BLOCKSFOUND step=-1} + +{/section} + + {if $GLOBAL.config.payout_system == 'pplns'} + +{section block $BLOCKSFOUND step=-1} + +{/section} + {/if} + {if $USEBLOCKAVERAGE} + +{section block $BLOCKSFOUND step=-1} + +{/section} + {/if} + +
Block Shares
{$BLOCKSFOUND[block].height}
Expected{$BLOCKSFOUND[block].estshares}
Actual{$BLOCKSFOUND[block].shares}
PPLNS{$BLOCKSFOUND[block].pplns_shares}
Average{$BLOCKSFOUND[block].block_avg}
+ + + + + + + + +
+ + + +
+

+

+The graph above illustrates N shares to find a block vs. E Shares expected to find a block based on +target and network difficulty and assuming a zero variance scenario. +

+
+{include file="global/block_footer.tpl"} \ No newline at end of file diff --git a/public/templates/mmcFE/statistics/blocks/block_shares_time.tpl b/public/templates/mmcFE/statistics/blocks/block_shares_time.tpl new file mode 100644 index 00000000..229facf9 --- /dev/null +++ b/public/templates/mmcFE/statistics/blocks/block_shares_time.tpl @@ -0,0 +1,27 @@ +{include file="global/block_header.tpl" BLOCK_HEADER="Block Shares" BLOCK_STYLE="clear:none;"} +

Last 24 hour totals

+ + + + + + + + + + + + + {assign var=percentage1 value=0} + + + + + + + + + +
Blocks FoundRewardsAvg DifficultyExpected SharesActual SharesPercentage
{$POOLSTATS.count|number_format:"0"}{$POOLSTATS.rewards|number_format:"4"}{$POOLSTATS.average|number_format:"4"}{$POOLSTATS.expected|number_format:"0"}{$POOLSTATS.shares|number_format:"0"}{if $POOLSTATS.shares > 0}{math assign="percentage1" equation="shares1 / estshares1 * 100" shares1=$POOLSTATS.shares estshares1=$POOLSTATS.expected}{/if} + {$percentage1|number_format:"2"}
+{include file="global/block_footer.tpl"} diff --git a/public/templates/mmcFE/statistics/blocks/blocks_found_details.tpl b/public/templates/mmcFE/statistics/blocks/blocks_found_details.tpl new file mode 100644 index 00000000..b9431854 --- /dev/null +++ b/public/templates/mmcFE/statistics/blocks/blocks_found_details.tpl @@ -0,0 +1,30 @@ +{include file="global/block_header.tpl" BLOCK_HEADER="Last $BLOCKLIMIT Blocks Found" BLOCK_STYLE="clear:none;"} +
+ + + + + + + + + + +{assign var=rank value=1} +{section block $BLOCKSFOUND} + + + + + + +{/section} + +
BlockFinderTimeActual Shares
{$BLOCKSFOUND[block].height}{if $BLOCKSFOUND[block].is_anonymous|default:"0" == 1 && $GLOBAL.userdata.is_admin|default:"0" == 0}anonymous{else}{$BLOCKSFOUND[block].finder|default:"unknown"|escape}{/if}{$BLOCKSFOUND[block].time|date_format:"%d/%m %H:%M:%S"}{$BLOCKSFOUND[block].shares|number_format}
+
+{if $GLOBAL.config.payout_system != 'pps'} + +{/if} +{include file="global/block_footer.tpl"} diff --git a/public/templates/mmcFE/statistics/blocks/default.tpl b/public/templates/mmcFE/statistics/blocks/default.tpl index 28fdd3d6..54264453 100644 --- a/public/templates/mmcFE/statistics/blocks/default.tpl +++ b/public/templates/mmcFE/statistics/blocks/default.tpl @@ -1,156 +1,4 @@ -{include file="global/block_header.tpl" BLOCK_HEADER="Block Shares" BLOCK_STYLE="clear:none;"} - - - - -{section block $BLOCKSFOUND step=-1} - -{/section} - - - - - -{section block $BLOCKSFOUND step=-1} - -{/section} - - - -{section block $BLOCKSFOUND step=-1} - -{/section} - - {if $GLOBAL.config.payout_system == 'pplns'} - -{section block $BLOCKSFOUND step=-1} - -{/section} - {/if} - {if $USEBLOCKAVERAGE} - -{section block $BLOCKSFOUND step=-1} - -{/section} - {/if} - -
Block Shares
{$BLOCKSFOUND[block].height}
Expected{$BLOCKSFOUND[block].estshares}
Actual{$BLOCKSFOUND[block].shares}
PPLNS{$BLOCKSFOUND[block].pplns_shares}
Average{$BLOCKSFOUND[block].block_avg}
-

-

-The graph above illustrates N shares to find a block vs. E Shares expected to find a block based on -target and network difficulty and assuming a zero variance scenario. -

- - - - - - - - - - - - - - - - - {assign var=percentage1 value=0} - - - - - - - - - -
Last 24 hour totals
Blocks FoundRewardsAvg DifficultyExpected SharesActual SharesPercentage
{$POOLSTATS.count|number_format:"0"}{$POOLSTATS.rewards|number_format:"4"}{$POOLSTATS.average|number_format:"4"}{$POOLSTATS.expected|number_format:"0"}{$POOLSTATS.shares|number_format:"0"}{if $POOLSTATS.shares > 0}{math assign="percentage1" equation="shares1 / estshares1 * 100" shares1=$POOLSTATS.shares estshares1=$POOLSTATS.expected}{/if} - {$percentage1|number_format:"2"}
- - - - - - - - -
- - - -
-
-{include file="global/block_footer.tpl"} - -{include file="global/block_header.tpl" BLOCK_HEADER="Last $BLOCKLIMIT Blocks Found" BLOCK_STYLE="clear:none;"} -
- - - - - - - - - - - {if $GLOBAL.config.payout_system == 'pplns'}{/if} - - - - - -{assign var=count value=0} -{assign var=totalexpectedshares value=0} -{assign var=totalshares value=0} -{assign var=totalpercentage value=0} -{assign var=pplnsshares value=0} -{section block $BLOCKSFOUND} - {assign var="totalshares" value=$totalshares+$BLOCKSFOUND[block].shares} - {assign var="count" value=$count+1} - {if $GLOBAL.config.payout_system == 'pplns'}{assign var="pplnsshares" value=$pplnsshares+$BLOCKSFOUND[block].pplns_shares}{/if} - - - - - - - - - {if $GLOBAL.config.payout_system == 'pplns'}{/if} - - - -{/section} - {if $count > 0} - - - - {if $GLOBAL.config.payout_system == 'pplns'}{/if} - - - {/if} - -
BlockValidityFinderTimeDifficultyAmountExpected SharesPPLNS SharesActual SharesPercentage
{$BLOCKSFOUND[block].height} - {if $BLOCKSFOUND[block].confirmations >= $GLOBAL.confirmations} - Confirmed - {else if $BLOCKSFOUND[block].confirmations == -1} - Orphan - {else}{$GLOBAL.confirmations - $BLOCKSFOUND[block].confirmations} left{/if}{if $BLOCKSFOUND[block].is_anonymous|default:"0" == 1 && $GLOBAL.userdata.is_admin|default:"0" == 0}anonymous{else}{$BLOCKSFOUND[block].finder|default:"unknown"|escape}{/if}{$BLOCKSFOUND[block].time|date_format:"%d/%m %H:%M:%S"}{$BLOCKSFOUND[block].difficulty|number_format:"8"}{$BLOCKSFOUND[block].amount|number_format:"2"} - {$BLOCKSFOUND[block].estshares|number_format} - {assign var="totalexpectedshares" value=$totalexpectedshares+$BLOCKSFOUND[block].estshares} - {$BLOCKSFOUND[block].pplns_shares|number_format}{$BLOCKSFOUND[block].shares|number_format} - {math assign="percentage" equation="shares / estshares * 100" shares=$BLOCKSFOUND[block].shares estshares=$BLOCKSFOUND[block].estshares} - {assign var="totalpercentage" value=$totalpercentage+$percentage} - {$percentage|number_format:"2"} -
Totals{$totalexpectedshares|number_format}{$pplnsshares|number_format}{$totalshares|number_format}{($totalpercentage / $count)|number_format:"2"} -
-
-{if $GLOBAL.config.payout_system != 'pps'} - -{/if} -{include file="global/block_footer.tpl"} +{include file="statistics/blocks/block_shares_graph.tpl"} +{include file="statistics/blocks/block_overview_time.tpl"} +{include file="statistics/blocks/block_shares_time.tpl"} +{include file="statistics/blocks/blocks_found_details.tpl"} \ No newline at end of file diff --git a/public/templates/mmcFE/statistics/pool/default.tpl b/public/templates/mmcFE/statistics/pool/default.tpl index 7cf67f68..6f5aeb23 100644 --- a/public/templates/mmcFE/statistics/pool/default.tpl +++ b/public/templates/mmcFE/statistics/pool/default.tpl @@ -51,31 +51,6 @@ {assign var=estshares value=(pow(2, (32 - $GLOBAL.config.target_bits)) * $DIFFICULTY) / pow(2, ($GLOBAL.config.targetdiff - 16))} {$estshares|number_format:"0"} (done: {(100 / $estshares * $GLOBAL.roundshares.valid)|number_format:"2"} %) - - All Blocks - Found / Valid / Orphan - {$FOUNDALLVALID + $FOUNDALLORPHAN} / {$FOUNDALLVALID} / {$FOUNDALLORPHAN} - - - Blocks last hour - Found / Valid / Orphan - {$FOUNDLASTHOURVALID + $FOUNDLASTHOURORPHAN} / {$FOUNDLASTHOURVALID} / {$FOUNDLASTHOURORPHAN} - - - Blocks last 24 hours - Found / Valid / Orphan - {$FOUNDLAST24HOURSVALID + $FOUNDLAST24HOURSORPHAN} / {$FOUNDLAST24HOURSVALID} / {$FOUNDLAST24HOURSORPHAN} - - - Blocks last 7 days - Found / Valid / Orphan - {$FOUNDLAST7DAYSVALID + $FOUNDLAST7DAYSORPHAN} / {$FOUNDLAST7DAYSVALID} / {$FOUNDLAST7DAYSORPHAN} - - - Blocks last 4 weeks - Found / Valid / Orphan - {$FOUNDLAST4WEEKSVALID + $FOUNDLAST4WEEKSORPHAN} / {$FOUNDLAST4WEEKSVALID} / {$FOUNDLAST4WEEKSORPHAN} - - - Time Since Last Block - {$TIMESINCELAST|seconds_to_words} - - {if !$GLOBAL.website.api.disabled}
  • These stats are also available in JSON format HERE
  • {/if} {include file="global/block_footer.tpl"} diff --git a/public/templates/mpos/statistics/blocks/block_overview_time.tpl b/public/templates/mpos/statistics/blocks/block_overview_time.tpl index 7b793a8b..434fb140 100644 --- a/public/templates/mpos/statistics/blocks/block_overview_time.tpl +++ b/public/templates/mpos/statistics/blocks/block_overview_time.tpl @@ -4,42 +4,62 @@ + Gen Est. Found Valid Orphan + Rate Est. All Time + {($FIRSTBLOCKFOUND / $COINGENTIME|default:"150")|number_format:"0"} {$LASTBLOCKSBYTIME.Total} {$LASTBLOCKSBYTIME.TotalValid} {$LASTBLOCKSBYTIME.TotalOrphan} + {($LASTBLOCKSBYTIME.Total|default:"0.00" / ($FIRSTBLOCKFOUND / $COINGENTIME|default:"150") * 100)|number_format:"2"} % Last Hour + {(3600 / $COINGENTIME|default:"150")} {$LASTBLOCKSBYTIME.1HourTotal} {$LASTBLOCKSBYTIME.1HourValid} {$LASTBLOCKSBYTIME.1HourOrphan} + {($LASTBLOCKSBYTIME.1HourTotal|default:"0.00" / (3600 / $COINGENTIME|default:"150") * 100)|number_format:"2"} % Last 24 Hours + {(86400 / $COINGENTIME|default:"150")} {$LASTBLOCKSBYTIME.24HourTotal} {$LASTBLOCKSBYTIME.24HourValid} {$LASTBLOCKSBYTIME.24HourOrphan} + {($LASTBLOCKSBYTIME.24HourTotal|default:"0.00" / (86400 / $COINGENTIME|default:"150") * 100)|number_format:"2"} % Last 7 Days + {(604800 / $COINGENTIME|default:"150")} {$LASTBLOCKSBYTIME.7DaysTotal} {$LASTBLOCKSBYTIME.7DaysValid} {$LASTBLOCKSBYTIME.7DaysOrphan} + {($LASTBLOCKSBYTIME.7DaysTotal|default:"0.00" / (604800 / $COINGENTIME|default:"150") * 100)|number_format:"2"} % Last 4 Weeks + {(2419200 / $COINGENTIME|default:"150")} {$LASTBLOCKSBYTIME.4WeeksTotal} {$LASTBLOCKSBYTIME.4WeeksValid} {$LASTBLOCKSBYTIME.4WeeksOrphan} + {($LASTBLOCKSBYTIME.4WeeksTotal|default:"0.00" / (2419200 / $COINGENTIME|default:"150") * 100)|number_format:"2"} % + + + Last 12 Month + {(29030400 / $COINGENTIME|default:"150")} + {$LASTBLOCKSBYTIME.12MonthTotal} + {$LASTBLOCKSBYTIME.12MonthValid} + {$LASTBLOCKSBYTIME.12MonthOrphan} + {($LASTBLOCKSBYTIME.12MonthTotal|default:"0.00" / (29030400 / $COINGENTIME|default:"150") * 100)|number_format:"2"} % - + \ No newline at end of file diff --git a/public/templates/mpos/statistics/blocks/block_shares_graph.tpl b/public/templates/mpos/statistics/blocks/block_shares_graph.tpl index fb27a2b9..cacbc2cf 100644 --- a/public/templates/mpos/statistics/blocks/block_shares_graph.tpl +++ b/public/templates/mpos/statistics/blocks/block_shares_graph.tpl @@ -36,6 +36,18 @@ {/if} + + + + + + + +
    + + + +