diff --git a/public/include/config/global.inc.dist.php b/public/include/config/global.inc.dist.php index 2fa14457..2cb38c6d 100644 --- a/public/include/config/global.inc.dist.php +++ b/public/include/config/global.inc.dist.php @@ -21,6 +21,8 @@ define('DEBUG', 5); define('SALT', 'LJKEHFuhgu7%&¤Hg783tr7gf¤%¤fyegfredfoGHYFGYe(%/(&%6'); $config = array( + 'difficulty' => '31', // Target difficulty for this pool + 'reward' => '50', // Reward for finding blocks 'wallet' => array( 'type' => 'http', // http or https are supported 'host' => 'localhost:9332', diff --git a/public/include/pages/statistics/pool.inc.php b/public/include/pages/statistics/pool.inc.php index acfdf9c2..36deb74f 100644 --- a/public/include/pages/statistics/pool.inc.php +++ b/public/include/pages/statistics/pool.inc.php @@ -4,8 +4,9 @@ if (!defined('SECURITY')) die('Hacking attempt'); +// Fetch data from litecoind if ($bitcoin->can_connect() === true){ - $iDifficulty = $bitcoin->query('getdifficulty'); + $dDifficulty = $bitcoin->query('getdifficulty'); $iBlock = $bitcoin->query('getblockcount'); } else { $iDifficulty = 1; @@ -13,8 +14,54 @@ if ($bitcoin->can_connect() === true){ $_SESSION['POPUP'][] = array('CONTENT' => 'Unable to connect to pushpool service: ' . $bitcoin->can_connect(), 'TYPE' => 'errormsg'); } +// TODO: For testing +$dDifficulty = 396; + +// Top 15 hashrate list +$stmt = $mysqli->prepare("SELECT username, id, hashrate FROM webUsers WHERE hashrate != '0' ORDER BY hashrate DESC LIMIT 15"); +$stmt->execute(); +$hashrates= $stmt->get_result(); +$aHashData = $hashrates->fetch_all(MYSQLI_ASSOC); +$stmt->close(); + +// Top 15 Contributors +# SELECT id, shares_this_round AS shares FROM webUsers WHERE shares_this_round > 0 ORDER BY shares DESC LIMIT +$stmt = $mysqli->prepare("SELECT id, shares_this_round AS shares, username FROM webUsers WHERE shares_this_round > 0 ORDER BY shares DESC LIMIT 15"); +$stmt->execute(); +$contributors = $stmt->get_result(); +$aContributorData = $contributors->fetch_all(MYSQLI_ASSOC); +$stmt->close(); + +// Grab the last block found +$stmt = $mysqli->prepare("SELECT n.blockNumber, n.confirms, n.timestamp FROM winning_shares w, networkBlocks n WHERE w.blockNumber = n.blockNumber ORDER BY w.blockNumber DESC LIMIT 1"); +$stmt->execute(); +$blocks = $stmt->get_result(); +$aBlockData = $blocks->fetch_array(); +$stmt->close(); + +// Grab the last 10 blocks found +$stmt = $mysqli->prepare("SELECT DISTINCT w.shareCount AS shares, w.username, n.blockNumber, n.confirms, n.timestamp FROM winning_shares w, networkBlocks n WHERE w.blockNumber = n.blockNumber ORDER BY w.blockNumber DESC LIMIT 10"); +$stmt->execute(); +$blocksfound = $stmt->get_result(); +$aBlocksFoundData = $blocksfound->fetch_all(MYSQLI_ASSOC); +$stmt->close(); + +// Estimated time to find the next block +$iEstTime = (($dDifficulty * bcpow(2,$config['difficulty'])) / ( $settings->getValue('currenthashrate') * 1000)); +$now = new DateTime( "now" ); +$dTimeSinceLast = ($now->getTimestamp() - $aBlockData['timestamp']); + +// Propagate content our template +$smarty->assign("ESTTIME", $iEstTime); +$smarty->assign("TIMESINCELAST", $dTimeSinceLast); +$smarty->assign("CONTRIBUTORS", $aContributorData); +$smarty->assign("BLOCKSFOUND", $aBlocksFoundData); +$smarty->assign("TOPHASHRATES", $aHashData); $smarty->assign("CURRENTBLOCK", $iBlock); -$smarty->assign("DIFFICULTY", $iDifficulty); +$smarty->assign("LASTBLOCK", $aBlockData['blockNumber']); +$smarty->assign("DIFFICULTY", $dDifficulty); +$smarty->assign("TARGETDIFF", $config['difficulty']); +$smarty->assign("REWARD", $config['reward']); if ($_SESSION['AUTHENTICATED']) { $smarty->assign("CONTENT", "authenticated.tpl"); diff --git a/public/include/smarty/libs/plugins/modifier.seconds_to_words.php b/public/include/smarty/libs/plugins/modifier.seconds_to_words.php new file mode 100644 index 00000000..fddf8c46 --- /dev/null +++ b/public/include/smarty/libs/plugins/modifier.seconds_to_words.php @@ -0,0 +1,22 @@ + 0) $out .= $hours . " hour". ($hours > 1 ? "s" : "")." "; + if ($minutes > 0) $out .= $minutes . " minute". ($minutes > 1 ? "s" : "")." "; + if ($seconds > 0) $out .= $seconds . " second". ($seconds > 1 ? "s" : ""); + return trim($out); +} diff --git a/public/templates/mmcFE/statistics/blocks/blocks_found.tpl b/public/templates/mmcFE/statistics/blocks/blocks_found.tpl new file mode 100644 index 00000000..a3801273 --- /dev/null +++ b/public/templates/mmcFE/statistics/blocks/blocks_found.tpl @@ -0,0 +1,31 @@ +{include file="global/block_header.tpl" BLOCK_HEADER="Last 10 Blocks Found" BLOCK_STYLE="clear:none;" BUTTONS=array(More)} +
+ + + + + + + + + + + +{assign var=rank value=1} +{section block $BLOCKSFOUND} + {assign var=user value="."|explode:$BLOCKSFOUND[block].username} + + + + + + + +{/section} + +
BlockValidityFinderDate / TimeShares
{$BLOCKSFOUND[block].blockNumber}{$BLOCKSFOUND[block].confirmed}{$user.0}{$BLOCKSFOUND[block].timestamp|date_format:"%d/%m/%Y %H:%M:%S"}{$BLOCKSFOUND[block].shares|number_format}
+
+ +{include file="global/block_footer.tpl"} diff --git a/public/templates/mmcFE/statistics/pool/authenticated.tpl b/public/templates/mmcFE/statistics/pool/authenticated.tpl index 073a685b..067d8934 100644 --- a/public/templates/mmcFE/statistics/pool/authenticated.tpl +++ b/public/templates/mmcFE/statistics/pool/authenticated.tpl @@ -11,12 +11,15 @@ - - 1 - TheSerapher - 576 -  4.045 +{assign var=rank value=1} +{section hashrate $TOPHASHRATES} + + {$rank++} + {$TOPHASHRATES[hashrate].username} + {$TOPHASHRATES[hashrate].hashrate|number_format} + {math equation="round(( 24 / (((diff * pow(2,targetdiff)) / (hashrate * 1000)) / 3600) * reward ),3)" diff=$DIFFICULTY targetdiff=$TARGETDIFF hashrate=$TOPHASHRATES[hashrate].hashrate reward=$REWARD} +{/section} @@ -29,11 +32,14 @@ RankUser NameShares - - 1 - TheSerapher - 94,133 +{assign var=rank value=1} +{section contributor $CONTRIBUTORS} + + {$rank++} + {$CONTRIBUTORS[contributor].username} + {$CONTRIBUTORS[contributor].shares|number_format} +{/section} @@ -44,7 +50,7 @@ Pool Hash Rate - {$GLOBAL.hashrate} Mhash/s + {$GLOBAL.hashrate / 1000} Mhash/s Current Workers Mining @@ -52,19 +58,23 @@ Next Network Block - 333,759    (Current: 333,758) + {$CURRENTBLOCK + 1}    (Current: {$CURRENTBLOCK}) + + + Last Block Found + {$LASTBLOCK} Current Difficulty - 293.35991187 + {$DIFFICULTY} Est. Avg. Time per Round - 205 Hours 40 Minutes + {$ESTTIME|seconds_to_words} Time Since Last Block - N/A + {$TIMESINCELAST|seconds_to_words} @@ -74,22 +84,6 @@ {include file="global/block_footer.tpl"} -{include file="global/block_header.tpl" BLOCK_HEADER="Last 10 Blocks Found" BLOCK_STYLE="clear:none;" BUTTONS=array(More)} -
- - - - - - - - - - -
BlockValidityFinderDate / TimeShares
-
- -{include file="global/block_footer.tpl"} +{include file="statistics/blocks/blocks_found.tpl"} + {include file="global/block_footer.tpl"}