diff --git a/public/include/config/admin_settings.inc.php b/public/include/config/admin_settings.inc.php index 69b55e75..6f99ac82 100644 --- a/public/include/config/admin_settings.inc.php +++ b/public/include/config/admin_settings.inc.php @@ -102,6 +102,27 @@ $aSettings['statistics'][] = array( 'name' => 'statistics_block_count', 'value' => $setting->getValue('statistics_block_count'), 'tooltip' => 'Blocks to fetch for the block statistics page.' ); +$aSettings['statistics'][] = array( + 'display' => 'Pool Hashrate Modifier', 'type' => 'select', + 'options' => array( '1' => 'KH/s', '0.001' => 'MH/s', '0.000001' => 'GH/s' ), + 'default' => '1', + 'name' => 'statistics_pool_hashrate_modifier', 'value' => $setting->getValue('statistics_pool_hashrate_modifier'), + 'tooltip' => 'Auto-adjust displayed pool hashrates to a certain limit.' +); +$aSettings['statistics'][] = array( + 'display' => 'Network Hashrate Modifier', 'type' => 'select', + 'options' => array( '1' => 'KH/s', '0.001' => 'MH/s', '0.000001' => 'GH/s' ), + 'default' => '1', + 'name' => 'statistics_network_hashrate_modifier', 'value' => $setting->getValue('statistics_network_hashrate_modifier'), + 'tooltip' => 'Auto-adjust displayed network hashrates to a certain limit.' +); +$aSettings['statistics'][] = array( + 'display' => 'Personal Hashrate Modifier', 'type' => 'select', + 'options' => array( '1' => 'KH/s', '0.001' => 'MH/s', '0.000001' => 'GH/s' ), + 'default' => '1', + 'name' => 'statistics_personal_hashrate_modifier', 'value' => $setting->getValue('statistics_personal_hashrate_modifier'), + 'tooltip' => 'Auto-adjust displayed personal hashrates to a certain limit.' +); $aSettings['acl'][] = array( 'display' => 'Pool Statistics', 'type' => 'select', 'options' => array( 0 => 'Private', 1 => 'Public'), diff --git a/public/include/smarty_globals.inc.php b/public/include/smarty_globals.inc.php index d457ee4e..acce6725 100644 --- a/public/include/smarty_globals.inc.php +++ b/public/include/smarty_globals.inc.php @@ -17,21 +17,45 @@ if ($bitcoin->can_connect() === true) { $dDifficulty = $bitcoin->query('getdifficulty'); if (is_array($dDifficulty) && array_key_exists('proof-of-work', $dDifficulty)) $dDifficulty = $dDifficulty['proof-of-work']; + try { $dNetworkHashrate = $bitcoin->query('getnetworkhashps') / 1000; } catch (Exception $e) { + // Maybe we are SHA + try { $dNetworkHashrate = $bitcoin->query('gethashespersec') / 1000; } catch (Exception $e) { + $dNetworkHashrate = 0; + } + $dNetworkHashrate = 0; + } +} else { + $dNetworkHashrate = 0; } -// Always fetch this since we need for ministats header -$bitcoin->can_connect() === true ? $dNetworkHashrate = $bitcoin->query('getnetworkhashps') : $dNetworkHashrate = 0; - -// Fetch some data -if (!$iCurrentActiveWorkers = $worker->getCountAllActiveWorkers()) $iCurrentActiveWorkers = 0; +// Baseline pool hashrate for templates +if ( ! $dPoolHashrateModifier = $setting->getValue('statistics_pool_hashrate_modifier') ) $dPoolHashrateModifier = 1; $iCurrentPoolHashrate = $statistics->getCurrentHashrate(); -$iCurrentPoolShareRate = $statistics->getCurrentShareRate(); // Avoid confusion, ensure our nethash isn't higher than poolhash if ($iCurrentPoolHashrate > $dNetworkHashrate) $dNetworkHashrate = $iCurrentPoolHashrate; +// Baseline network hashrate for templates +if ( ! $dPersonalHashrateModifier = $setting->getValue('statistics_personal_hashrate_modifier') ) $dPersonalHashrateModifier = 1; +if ( ! $dNetworkHashrateModifier = $setting->getValue('statistics_network_hashrate_modifier') ) $dNetworkHashrateModifier = 1; + +// Apply modifier now +$dNetworkHashrate = $dNetworkHashrate * $dNetworkHashrateModifier; +$iCurrentPoolHashrate = $iCurrentPoolHashrate * $dPoolHashrateModifier; + +// Share rate of the entire pool +$iCurrentPoolShareRate = $statistics->getCurrentShareRate(); + +// Active workers +if (!$iCurrentActiveWorkers = $worker->getCountAllActiveWorkers()) $iCurrentActiveWorkers = 0; + +// Small helper array +$aHashunits = array( '1' => 'KH/s', '0.001' => 'MH/s', '0.000001' => 'GH/s' ); + // Global data for Smarty $aGlobal = array( + 'hashunits' => array( 'pool' => $aHashunits[$dPoolHashrateModifier], 'network' => $aHashunits[$dNetworkHashrateModifier], 'personal' => $aHashunits[$dPersonalHashrateModifier]), + 'hashmods' => array( 'personal' => $dPersonalHashrateModifier ), 'hashrate' => $iCurrentPoolHashrate, 'nethashrate' => $dNetworkHashrate, 'sharerate' => $iCurrentPoolShareRate, @@ -93,7 +117,7 @@ if (@$_SESSION['USERDATA']['id']) { // Other userdata that we can cache savely $aGlobal['userdata']['shares'] = $statistics->getUserShares($_SESSION['USERDATA']['id']); - $aGlobal['userdata']['hashrate'] = $statistics->getUserHashrate($_SESSION['USERDATA']['id']); + $aGlobal['userdata']['hashrate'] = $statistics->getUserHashrate($_SESSION['USERDATA']['id']) * $dPersonalHashrateModifier; $aGlobal['userdata']['sharerate'] = $statistics->getUserSharerate($_SESSION['USERDATA']['id']); switch ($config['payout_system']) { diff --git a/public/templates/mmcFE/global/header.tpl b/public/templates/mmcFE/global/header.tpl index 9b03db7e..4d2e9b18 100644 --- a/public/templates/mmcFE/global/header.tpl +++ b/public/templates/mmcFE/global/header.tpl @@ -5,8 +5,8 @@ {if $GLOBAL.config.price.currency}{/if} - - + + diff --git a/public/templates/mmcFE/global/sidebar_pplns.tpl b/public/templates/mmcFE/global/sidebar_pplns.tpl index a39bce8d..fa11f94d 100644 --- a/public/templates/mmcFE/global/sidebar_pplns.tpl +++ b/public/templates/mmcFE/global/sidebar_pplns.tpl @@ -16,7 +16,7 @@ - + diff --git a/public/templates/mmcFE/global/sidebar_pps.tpl b/public/templates/mmcFE/global/sidebar_pps.tpl index 1268880a..2759fc27 100644 --- a/public/templates/mmcFE/global/sidebar_pps.tpl +++ b/public/templates/mmcFE/global/sidebar_pps.tpl @@ -11,7 +11,7 @@ - + diff --git a/public/templates/mmcFE/global/sidebar_prop.tpl b/public/templates/mmcFE/global/sidebar_prop.tpl index 69afe6ee..3c6206e0 100644 --- a/public/templates/mmcFE/global/sidebar_prop.tpl +++ b/public/templates/mmcFE/global/sidebar_prop.tpl @@ -11,7 +11,7 @@ - + diff --git a/public/templates/mmcFE/statistics/pool/authenticated.tpl b/public/templates/mmcFE/statistics/pool/authenticated.tpl index b19848db..870909c5 100644 --- a/public/templates/mmcFE/statistics/pool/authenticated.tpl +++ b/public/templates/mmcFE/statistics/pool/authenticated.tpl @@ -9,7 +9,7 @@ - + diff --git a/public/templates/mmcFE/statistics/pool/contributors_hashrate.tpl b/public/templates/mmcFE/statistics/pool/contributors_hashrate.tpl index a7f3cd9f..212a4695 100644 --- a/public/templates/mmcFE/statistics/pool/contributors_hashrate.tpl +++ b/public/templates/mmcFE/statistics/pool/contributors_hashrate.tpl @@ -5,7 +5,7 @@ - + {if $GLOBAL.config.price.currency}{/if} @@ -18,7 +18,7 @@ - + {if $GLOBAL.config.price.currency}{/if}
  • {$GLOBAL.config.currency}/{$GLOBAL.config.price.currency}: {$GLOBAL.price|default:"0"|number_format:"4"}    
  • Network Hashrate: {($GLOBAL.nethashrate / 1000 / 1000 )|default:"0"|number_format:"3"} MH/s    
  • Pool Hashrate: {($GLOBAL.hashrate / 1000)|number_format:"3"} MH/s    
  • Network Hashrate: {$GLOBAL.nethashrate|default:"0"|number_format:"3"} {$GLOBAL.hashunits.network}    
  • Pool Hashrate: {$GLOBAL.hashrate|number_format:"3"} {$GLOBAL.hashunits.pool}    
  • Pool Sharerate: {$GLOBAL.sharerate|number_format:"2"} Shares/s    
  • Pool Workers: {$GLOBAL.workers|default:"0"}    
  • Hashrate{$GLOBAL.userdata.hashrate|number_format} KH/s{$GLOBAL.userdata.hashrate|number_format:"2"} {$GLOBAL.hashunits.personal}
    Unpaid Shares
    Hashrate{$GLOBAL.userdata.hashrate|number_format} KH/s{$GLOBAL.userdata.hashrate|number_format:"2"} {$GLOBAL.hashunits.personal}
    Share Rate
    Hashrate{$GLOBAL.userdata.hashrate|number_format} KH/s{$GLOBAL.userdata.hashrate|number_format:"2"} {$GLOBAL.hashunits.personal}
    Unpaid Shares
    Pool Hash Rate{($GLOBAL.hashrate / 1000)|number_format:"3"} Mhash/s{$GLOBAL.hashrate|number_format:"3"} {$GLOBAL.hashunits.pool}
    Pool Efficiency
    Rank User NameKH/s{$GLOBAL.hashunits.personal} {$GLOBAL.config.currency}/Day{$GLOBAL.config.price.currency}/Day
    {$rank++} {if $CONTRIBHASHES[contrib].is_anonymous|default:"0" == 1}anonymous{else}{$CONTRIBHASHES[contrib].account|escape}{/if}{$CONTRIBHASHES[contrib].hashrate|number_format}{($CONTRIBHASHES[contrib].hashrate * $GLOBAL.hashmods.personal)|number_format:"2"} {$estday|number_format:"3"}{($estday * $GLOBAL.price)|default:"n/a"|number_format:"2"}