Skip to content

Lowdiff shares (2nd update #2718) #2728

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 4 commits into from
May 12, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion include/classes/block.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -237,7 +237,7 @@ public function setShareId($block_id, $share_id) {
* @return bool
**/
public function setShares($block_id, $shares=NULL) {
$field = array( 'name' => 'shares', 'value' => $shares, 'type' => 'i');
$field = array( 'name' => 'shares', 'value' => $shares, 'type' => 'd');
return $this->updateSingle($block_id, $field);
}

Expand Down
2 changes: 1 addition & 1 deletion include/classes/coins/coin_base.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ public function calcHashrate($shares, $interval) {
* according to our configuration difficulty
**/
public function calcEstaimtedShares($dDifficulty) {
return (int)round(pow(2, (32 - $this->target_bits)) * $dDifficulty, 0);
return (float)round(pow(2, (32 - $this->target_bits)) * $dDifficulty, $this->share_difficulty_precision);
}

/**
Expand Down
6 changes: 3 additions & 3 deletions include/classes/statistics.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ public function getBlocksFound($limit=10) {
b.*,
a.username AS finder,
a.is_anonymous AS is_anonymous,
ROUND(difficulty * POW(2, 32 - " . $this->coin->getTargetBits() . "), 0) AS estshares
ROUND(difficulty * POW(2, 32 - " . $this->coin->getTargetBits() . "), " . $this->coin->getShareDifficultyPrecision() . ") AS estshares
FROM " . $this->block->getTableName() . " AS b
LEFT JOIN " . $this->user->getTableName() . " AS a
ON b.account_id = a.id
Expand Down Expand Up @@ -261,12 +261,12 @@ public function getCurrentShareRate($interval=180) {
SELECT
(
(
SELECT ROUND(SUM(difficulty) / ?, 2) AS sharerate
SELECT ROUND(SUM(difficulty) / ?, " . $this->coin->getShareDifficultyPrecision() . ") AS sharerate
FROM " . $this->share->getTableName() . "
WHERE time > DATE_SUB(now(), INTERVAL ? SECOND)
AND our_result = 'Y'
) + (
SELECT ROUND(SUM(difficulty) / ?, 2) AS sharerate
SELECT ROUND(SUM(difficulty) / ?, " . $this->coin->getShareDifficultyPrecision() . ") AS sharerate
FROM " . $this->share->getArchiveTableName() . "
WHERE time > DATE_SUB(now(), INTERVAL ? SECOND)
AND our_result = 'Y'
Expand Down
2 changes: 1 addition & 1 deletion include/classes/worker.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -174,7 +174,7 @@ public function getWorkers($account_id, $interval=600) {
while ($row = $result->fetch_assoc()) {
$row['hashrate'] = round($this->coin->calcHashrate($row['shares'], $interval), 2);
if ($row['count_all'] > 0) {
$row['difficulty'] = round($row['shares'] / $row['count_all'], 2);
$row['difficulty'] = round($row['shares'] / $row['count_all'], $this->coin->getShareDifficultyPrecision());
} else {
$row['difficulty'] = 0.00;
}
Expand Down
10 changes: 5 additions & 5 deletions sql/000_base_structure.sql
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ CREATE TABLE IF NOT EXISTS `blocks` (
`accounted` tinyint(1) NOT NULL DEFAULT '0',
`account_id` int(255) unsigned DEFAULT NULL,
`worker_name` varchar(50) DEFAULT 'unknown',
`shares` bigint(30) unsigned DEFAULT NULL,
`shares` double unsigned DEFAULT NULL,
`share_id` bigint(30) DEFAULT NULL,
PRIMARY KEY (`id`),
UNIQUE KEY `height` (`height`,`blockhash`),
Expand Down Expand Up @@ -182,10 +182,10 @@ CREATE TABLE IF NOT EXISTS `statistics_shares` (
`id` int(10) unsigned NOT NULL AUTO_INCREMENT,
`account_id` int(10) unsigned NOT NULL,
`block_id` int(10) unsigned NOT NULL,
`valid` float NOT NULL DEFAULT '0',
`invalid` float NOT NULL DEFAULT '0',
`pplns_valid` float NOT NULL DEFAULT '0',
`pplns_invalid` float NOT NULL DEFAULT '0',
`valid` float unsigned NOT NULL DEFAULT '0',
`invalid` float unsigned NOT NULL DEFAULT '0',
`pplns_valid` float unsigned NOT NULL DEFAULT '0',
`pplns_invalid` float unsigned NOT NULL DEFAULT '0',
PRIMARY KEY (`id`),
KEY `account_id` (`account_id`),
KEY `block_id` (`block_id`)
Expand Down
6 changes: 3 additions & 3 deletions templates/bootstrap/dashboard/blocks/default.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,8 @@
<td class="text-right">{$BLOCKSFOUND[block].time|date_format:$GLOBAL.config.date}</td>
<td class="text-right">{$BLOCKSFOUND[block].difficulty|number_format:"4"}</td>
<td class="text-right">{$BLOCKSFOUND[block].amount|number_format:"2"}</td>
<td class="text-right">{$BLOCKSFOUND[block].estshares|number_format}</td>
<td class="text-right">{$BLOCKSFOUND[block].shares|number_format}</td>
<td class="text-right">{$BLOCKSFOUND[block].estshares|number_format:$GLOBAL.config.sharediffprecision}</td>
<td class="text-right">{$BLOCKSFOUND[block].shares|number_format:$GLOBAL.config.sharediffprecision}</td>
<td class="text-right">
{math assign="percentage" equation="shares / estshares * 100" shares=$BLOCKSFOUND[block].shares|default:"0" estshares=$BLOCKSFOUND[block].estshares}
<font color="{if ($percentage <= 100)}green{else}red{/if}">{$percentage|number_format:"2"}</font>
Expand All @@ -46,4 +46,4 @@
{/if}
</div>
</div>
{/if}
{/if}
6 changes: 3 additions & 3 deletions templates/bootstrap/dashboard/js/api.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ $(document).ready(function(){

// Load initial sparkline values
var storedPersonalHashrate = [ null, null, null, null, null, null, null, null, null, null, null, null, {/literal}{$GLOBAL.userdata.hashrate|round:"2"}{literal} ];
var storedPersonalSharerate = [ null, null, null, null, null, null, null, null, null, null, null, null, {/literal}{$GLOBAL.userdata.sharerate|round:"2"}{literal} ];
var storedPersonalSharerate = [ null, null, null, null, null, null, null, null, null, null, null, null, {/literal}{$GLOBAL.userdata.sharerate|round:$GLOBAL.config.sharediffprecision}{literal} ];
var storedPoolHashrate = [ null, null, null, null, null, null, null, null, null, null, null, null, {/literal}{$GLOBAL.hashrate|round:"2"}{literal} ];
var storedNetHashrate = [ null, null, null, null, null, null, null, null, null, null, null, null, {/literal}{$GLOBAL.nethashrate|round:"2"}{literal} ];
var storedPoolWorkers = [ null, null, null, null, null, null, null, null, null, null, null, null, {/literal}{$GLOBAL.workers}{literal} ];
Expand Down Expand Up @@ -89,7 +89,7 @@ $(document).ready(function(){
storedPersonalHashrate.shift();
storedPersonalHashrate.push(parseFloat(data.getdashboarddata.data.personal.hashrate).toFixed(2))
storedPersonalSharerate.shift();
storedPersonalSharerate.push(parseFloat(data.getdashboarddata.data.personal.sharerate).toFixed(2))
storedPersonalSharerate.push(parseFloat(data.getdashboarddata.data.personal.sharerate).toFixed({/literal}{$GLOBAL.config.sharediffprecision}{literal}))
storedPoolHashrate.shift();
storedPoolHashrate.push(parseFloat(data.getdashboarddata.data.pool.hashrate).toFixed(2))
storedNetHashrate.shift();
Expand Down Expand Up @@ -122,7 +122,7 @@ $(document).ready(function(){
} else {
$('#b-nethashrate').html('n/a');
}
$('#b-sharerate').html((parseFloat(data.getdashboarddata.data.personal.sharerate).toFixed(2)));
$('#b-sharerate').html((parseFloat(data.getdashboarddata.data.personal.sharerate).toFixed({/literal}{$GLOBAL.config.sharediffprecision}{literal})));
$('#b-yvalid').html(number_format(data.getdashboarddata.data.personal.shares.valid, {/literal}{$GLOBAL.config.sharediffprecision}{literal}));
$('#b-yivalid').html(number_format(data.getdashboarddata.data.personal.shares.invalid, {/literal}{$GLOBAL.config.sharediffprecision}{literal}));
if ( data.getdashboarddata.data.personal.shares.valid > 0 ) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@
<div class="circle-tile-description text-faded">
<p class="h5 up-more">My Sharerate</p>
<div class="circle-tile-number text-faded up">
<span class="overview" id="b-sharerate">{$GLOBAL.userdata.sharerate|number_format:"2"}</span>
<span class="overview" id="b-sharerate">{$GLOBAL.userdata.sharerate|number_format:$GLOBAL.config.sharediffprecision}</span>
<span class="overview-mhs"> S/s</span>
<br>
<span class="personal-sharerate-bar spark-18"></span>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@
<div class="circle-tile-description text-faded">
<p class="h5 up-more">My Sharerate</p>
<div class="circle-tile-number text-faded up">
<span class="overview" id="b-sharerate">{$GLOBAL.userdata.sharerate|number_format:"2"}</span>
<span class="overview" id="b-sharerate">{$GLOBAL.userdata.sharerate|number_format:$GLOBAL.config.sharediffprecision}</span>
<span class="overview-mhs"> S/s</span>
<br>
<span class="personal-sharerate-bar spark-18"></span>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@
<p class="h5" id="b-nextdiff">{if $GLOBAL.nethashrate > 0}{$NETWORK.EstNextDifficulty|number_format:"8"}{else}n/a{/if}</p>
</div>
<div class="circle-tile-number text-faded">
<p class="h6">Est. Next Difficulty{if $GLOBAL.config.coindiffchangetarget > 1}{if $GLOBAL.nethashrate > 0}<br/>Change in {$NETWORK.BlocksUntilDiffChange} Blocks{else}No Estimates{/if}{/if}</p>
<p class="h6">Est. Next Difficulty{if $GLOBAL.config.coindiffchangetarget|default:2016 > 1}{if $GLOBAL.nethashrate > 0}<br/>Change in {$NETWORK.BlocksUntilDiffChange} Blocks{else}No Estimates{/if}{/if}</p>
</div>
</div>
</div>
Expand Down
24 changes: 12 additions & 12 deletions templates/bootstrap/statistics/blocks/block_overview_time.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,8 @@
0
{/if}
</td>
<td class="text-right">{$LASTBLOCKSBYTIME.TotalEstimatedShares|number_format}</td>
<td class="text-right">{$LASTBLOCKSBYTIME.TotalShares|number_format}</td>
<td class="text-right">{$LASTBLOCKSBYTIME.TotalEstimatedShares|number_format:$GLOBAL.config.sharediffprecision}</td>
<td class="text-right">{$LASTBLOCKSBYTIME.TotalShares|number_format:$GLOBAL.config.sharediffprecision}</td>
<td class="text-right">
{if $LASTBLOCKSBYTIME.TotalEstimatedShares > 0}
<font color="{if (($LASTBLOCKSBYTIME.TotalShares / $LASTBLOCKSBYTIME.TotalEstimatedShares * 100) <= 100)}green{elseif (($LASTBLOCKSBYTIME.TotalShares / $LASTBLOCKSBYTIME.TotalEstimatedShares * 100) <= 115)}orange{else}red{/if}">{($LASTBLOCKSBYTIME.TotalShares / $LASTBLOCKSBYTIME.TotalEstimatedShares * 100)|number_format:"2"}%</font></b>
Expand All @@ -64,8 +64,8 @@
0
{/if}
</td>
<td class="text-right">{$LASTBLOCKSBYTIME.1HourEstimatedShares|number_format}</td>
<td class="text-right">{$LASTBLOCKSBYTIME.1HourShares|number_format}</td>
<td class="text-right">{$LASTBLOCKSBYTIME.1HourEstimatedShares|number_format:$GLOBAL.config.sharediffprecision}</td>
<td class="text-right">{$LASTBLOCKSBYTIME.1HourShares|number_format:$GLOBAL.config.sharediffprecision}</td>
<td class="text-right">
{if $LASTBLOCKSBYTIME.1HourEstimatedShares > 0}
<font color="{if (($LASTBLOCKSBYTIME.1HourShares / $LASTBLOCKSBYTIME.1HourEstimatedShares * 100) <= 100)}green{elseif (($LASTBLOCKSBYTIME.1HourShares / $LASTBLOCKSBYTIME.1HourEstimatedShares * 100) <= 115)}orange{else}red{/if}">{($LASTBLOCKSBYTIME.1HourShares / $LASTBLOCKSBYTIME.1HourEstimatedShares * 100)|number_format:"2"}%</font></b>
Expand All @@ -90,8 +90,8 @@
0
{/if}
</td>
<td class="text-right">{$LASTBLOCKSBYTIME.24HourEstimatedShares|number_format}</td>
<td class="text-right">{$LASTBLOCKSBYTIME.24HourShares|number_format}</td>
<td class="text-right">{$LASTBLOCKSBYTIME.24HourEstimatedShares|number_format:$GLOBAL.config.sharediffprecision}</td>
<td class="text-right">{$LASTBLOCKSBYTIME.24HourShares|number_format:$GLOBAL.config.sharediffprecision}</td>
<td class="text-right">
{if $LASTBLOCKSBYTIME.24HourEstimatedShares > 0}
<font color="{if (($LASTBLOCKSBYTIME.24HourShares / $LASTBLOCKSBYTIME.24HourEstimatedShares * 100) <= 100)}green{elseif (($LASTBLOCKSBYTIME.24HourShares / $LASTBLOCKSBYTIME.24HourEstimatedShares * 100) <= 115)}orange{else}red{/if}">{($LASTBLOCKSBYTIME.24HourShares / $LASTBLOCKSBYTIME.24HourEstimatedShares * 100)|number_format:"2"}%</font></b>
Expand All @@ -116,8 +116,8 @@
0
{/if}
</td>
<td class="text-right">{$LASTBLOCKSBYTIME.7DaysEstimatedShares|number_format}</td>
<td class="text-right">{$LASTBLOCKSBYTIME.7DaysShares|number_format}</td>
<td class="text-right">{$LASTBLOCKSBYTIME.7DaysEstimatedShares|number_format:$GLOBAL.config.sharediffprecision}</td>
<td class="text-right">{$LASTBLOCKSBYTIME.7DaysShares|number_format:$GLOBAL.config.sharediffprecision}</td>
<td class="text-right">
{if $LASTBLOCKSBYTIME.7DaysEstimatedShares > 0}
<font color="{if (($LASTBLOCKSBYTIME.7DaysShares / $LASTBLOCKSBYTIME.7DaysEstimatedShares * 100) <= 100)}green{elseif (($LASTBLOCKSBYTIME.7DaysShares / $LASTBLOCKSBYTIME.7DaysEstimatedShares * 100) <= 115)}orange{else}red{/if}">{($LASTBLOCKSBYTIME.7DaysShares / $LASTBLOCKSBYTIME.7DaysEstimatedShares * 100)|number_format:"2"}%</font></b>
Expand All @@ -142,8 +142,8 @@
0
{/if}
</td>
<td class="text-right">{$LASTBLOCKSBYTIME.4WeeksEstimatedShares|number_format}</td>
<td class="text-right">{$LASTBLOCKSBYTIME.4WeeksShares|number_format}</td>
<td class="text-right">{$LASTBLOCKSBYTIME.4WeeksEstimatedShares|number_format:$GLOBAL.config.sharediffprecision}</td>
<td class="text-right">{$LASTBLOCKSBYTIME.4WeeksShares|number_format:$GLOBAL.config.sharediffprecision}</td>
<td class="text-right">
{if $LASTBLOCKSBYTIME.4WeeksEstimatedShares > 0}
<font color="{if (($LASTBLOCKSBYTIME.4WeeksShares / $LASTBLOCKSBYTIME.4WeeksEstimatedShares * 100) <= 100)}green{elseif (($LASTBLOCKSBYTIME.4WeeksShares / $LASTBLOCKSBYTIME.4WeeksEstimatedShares * 100) <= 115)}orange{else}red{/if}">{($LASTBLOCKSBYTIME.4WeeksShares / $LASTBLOCKSBYTIME.4WeeksEstimatedShares * 100)|number_format:"2"}%</font></b>
Expand All @@ -168,8 +168,8 @@
0
{/if}
</td>
<td class="text-right">{$LASTBLOCKSBYTIME.12MonthEstimatedShares|number_format}</td>
<td class="text-right">{$LASTBLOCKSBYTIME.12MonthShares|number_format}</td>
<td class="text-right">{$LASTBLOCKSBYTIME.12MonthEstimatedShares|number_format:$GLOBAL.config.sharediffprecision}</td>
<td class="text-right">{$LASTBLOCKSBYTIME.12MonthShares|number_format:$GLOBAL.config.sharediffprecision}</td>
<td class="text-right">
{if $LASTBLOCKSBYTIME.12MonthEstimatedShares > 0}
<font color="{if (($LASTBLOCKSBYTIME.12MonthShares / $LASTBLOCKSBYTIME.12MonthEstimatedShares * 100) <= 100)}green{elseif (($LASTBLOCKSBYTIME.12MonthShares / $LASTBLOCKSBYTIME.12MonthEstimatedShares * 100) <= 115)}orange{else}red{/if}">{($LASTBLOCKSBYTIME.12MonthShares / $LASTBLOCKSBYTIME.12MonthEstimatedShares * 100)|number_format:"2"}%</font></b>
Expand Down
12 changes: 6 additions & 6 deletions templates/bootstrap/statistics/blocks/blocks_found_details.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -51,12 +51,12 @@
<td class="text-right">{$BLOCKSFOUND[block].amount|number_format:"2"}</td>
<td class="text-right">
{assign var="totalexpectedshares" value=$totalexpectedshares+$BLOCKSFOUND[block].estshares}
{$BLOCKSFOUND[block].estshares|number_format}
{$BLOCKSFOUND[block].estshares|number_format:$GLOBAL.config.sharediffprecision}
</td>
{if $GLOBAL.config.payout_system == 'pplns'}
<td class="text-right">{$BLOCKSFOUND[block].pplns_shares|number_format}</td>
<td class="text-right">{$BLOCKSFOUND[block].pplns_shares|number_format:$GLOBAL.config.sharediffprecision}</td>
{/if}
<td class="text-right">{$BLOCKSFOUND[block].shares|number_format}</td>
<td class="text-right">{$BLOCKSFOUND[block].shares|number_format:$GLOBAL.config.sharediffprecision}</td>
<td class="text-right">
{math assign="percentage" equation="shares / estshares * 100" shares=$BLOCKSFOUND[block].shares|default:"0" estshares=$BLOCKSFOUND[block].estshares}
<font color="{if ($percentage <= 100)}green{elseif ($percentage <= 115)}orange{else}red{/if}">{$percentage|number_format:"2"}</font>
Expand All @@ -65,11 +65,11 @@
{/section}
<tr>
<td colspan="6"><b>Totals</b></td>
<td class="text-right">{$totalexpectedshares|number_format}</td>
<td class="text-right">{$totalexpectedshares|number_format:$GLOBAL.config.sharediffprecision}</td>
{if $GLOBAL.config.payout_system == 'pplns'}
<td class="text-right">{$pplnsshares|number_format}</td>
<td class="text-right">{$pplnsshares|number_format:$GLOBAL.config.sharediffprecision}</td>
{/if}
<td class="text-right">{$totalshares|number_format}</td>
<td class="text-right">{$totalshares|number_format:$GLOBAL.config.sharediffprecision}</td>
<td class="text-right">{if $count > 0}<font color="{if (($totalshares / $totalexpectedshares * 100) <= 100)}green{elseif (($totalshares / $totalexpectedshares * 100) <= 115)}orange{else}red{/if}">{($totalshares / $totalexpectedshares * 100)|number_format:"2"}</font>{else}0{/if}</td>
</tr>
</tbody>
Expand Down
2 changes: 1 addition & 1 deletion templates/bootstrap/statistics/blocks/small_table.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
{/if}
<td>{if $BLOCKSFOUND[block].is_anonymous|default:"0" == 1 && $GLOBAL.userdata.is_admin|default:"0" == 0}anonymous{else}{$BLOCKSFOUND[block].finder|default:"unknown"|escape}{/if}</td>
<td>{$BLOCKSFOUND[block].time|date_format:$GLOBAL.config.date}</td>
<td class="text-right">{$BLOCKSFOUND[block].shares|number_format}</td>
<td class="text-right">{$BLOCKSFOUND[block].shares|number_format:$GLOBAL.config.sharediffprecision}</td>
</tr>
{/section}
</tbody>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@
{/section}
{if $listed != 1 && $GLOBAL.userdata.username|default:"" && $GLOBAL.userdata.rawhashrate|default:"0" > 0}
{math assign="myestday" equation="round(reward / ( diff * pow(2,32) / ( hashrate * 1000 ) / 3600 / 24), 3)" diff=$DIFFICULTY reward=$REWARD hashrate=$GLOBAL.userdata.rawhashrate}
{if $GLOBAL.userdata.username|default:""|lower == $CONTRIBHASHES[contrib].account|lower}{assign var=listed value=1}<tr class="success">{else}<tr>{/if}
{if $GLOBAL.userdata.username|default:""|lower == $CONTRIBHASHES[contrib].account|default:""|lower}{assign var=listed value=1}<tr class="success">{else}<tr>{/if}
<td>n/a</td>
<td>{if $GLOBAL.userdata.donate_percent|default:"0" >= 2}<i class="fa fa-trophy fa-fw"></i>{elseif $GLOBAL.userdata.donate_percent|default:"0" < 2 AND $GLOBAL.userdata.donate_percent|default:"0" > 0}<i class="fa fa-star-o fa-fw"></i>{else}<i class="fa fa-ban fa-fw"></i>{/if}</td>
<td>{$GLOBAL.userdata.username|escape}</td>
Expand Down
Loading