Skip to content

Commit b183ff1

Browse files
committed
lowdiff updates
1 parent 8cfc43e commit b183ff1

25 files changed

+59
-58
lines changed

include/classes/block.class.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -237,7 +237,7 @@ public function setShareId($block_id, $share_id) {
237237
* @return bool
238238
**/
239239
public function setShares($block_id, $shares=NULL) {
240-
$field = array( 'name' => 'shares', 'value' => $shares, 'type' => 'i');
240+
$field = array( 'name' => 'shares', 'value' => $shares, 'type' => 'd');
241241
return $this->updateSingle($block_id, $field);
242242
}
243243

include/classes/coins/coin_base.class.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ public function calcHashrate($shares, $interval) {
6060
* according to our configuration difficulty
6161
**/
6262
public function calcEstaimtedShares($dDifficulty) {
63-
return (int)round(pow(2, (32 - $this->target_bits)) * $dDifficulty, 0);
63+
return (float)round(pow(2, (32 - $this->target_bits)) * $dDifficulty, $this->share_difficulty_precision);
6464
}
6565

6666
/**

include/classes/statistics.class.php

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -111,7 +111,7 @@ public function getBlocksFound($limit=10) {
111111
b.*,
112112
a.username AS finder,
113113
a.is_anonymous AS is_anonymous,
114-
ROUND(difficulty * POW(2, 32 - " . $this->coin->getTargetBits() . "), 0) AS estshares
114+
ROUND(difficulty * POW(2, 32 - " . $this->coin->getTargetBits() . "), " . $this->coin->getShareDifficultyPrecision() . ") AS estshares
115115
FROM " . $this->block->getTableName() . " AS b
116116
LEFT JOIN " . $this->user->getTableName() . " AS a
117117
ON b.account_id = a.id
@@ -261,12 +261,12 @@ public function getCurrentShareRate($interval=180) {
261261
SELECT
262262
(
263263
(
264-
SELECT ROUND(SUM(difficulty) / ?, 2) AS sharerate
264+
SELECT ROUND(SUM(difficulty) / ?, " . $this->coin->getShareDifficultyPrecision() . ") AS sharerate
265265
FROM " . $this->share->getTableName() . "
266266
WHERE time > DATE_SUB(now(), INTERVAL ? SECOND)
267267
AND our_result = 'Y'
268268
) + (
269-
SELECT ROUND(SUM(difficulty) / ?, 2) AS sharerate
269+
SELECT ROUND(SUM(difficulty) / ?, " . $this->coin->getShareDifficultyPrecision() . ") AS sharerate
270270
FROM " . $this->share->getArchiveTableName() . "
271271
WHERE time > DATE_SUB(now(), INTERVAL ? SECOND)
272272
AND our_result = 'Y'
@@ -575,9 +575,9 @@ public function getUserMiningStats($username, $account_id=NULL, $interval=180) {
575575
if ($this->getGetCache() && $data = $this->memcache->get(__FUNCTION__ . $account_id)) return $data;
576576
$stmt = $this->mysqli->prepare("
577577
SELECT
578-
IFNULL(SUM(difficulty) / ?, 0) AS sharerate,
579-
IFNULL(SUM(difficulty), 0) AS shares,
580-
IFNULL(AVG(difficulty), 0) AS avgsharediff
578+
IFNULL(SUM(difficulty) / ?, " . $this->coin->getShareDifficultyPrecision() . ") AS sharerate,
579+
IFNULL(SUM(difficulty), " . $this->coin->getShareDifficultyPrecision() . ") AS shares,
580+
IFNULL(AVG(difficulty), " . $this->coin->getShareDifficultyPrecision() . ") AS avgsharediff
581581
FROM (
582582
SELECT
583583
id, our_result, IF(difficulty = 0, POW(2, (" . $this->config['difficulty'] . " - 16)), difficulty) AS difficulty

include/classes/worker.class.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -174,7 +174,7 @@ public function getWorkers($account_id, $interval=600) {
174174
while ($row = $result->fetch_assoc()) {
175175
$row['hashrate'] = round($this->coin->calcHashrate($row['shares'], $interval), 2);
176176
if ($row['count_all'] > 0) {
177-
$row['difficulty'] = round($row['shares'] / $row['count_all'], 2);
177+
$row['difficulty'] = round($row['shares'] / $row['count_all'], $this->coin->getShareDifficultyPrecision());
178178
} else {
179179
$row['difficulty'] = 0.00;
180180
}

sql/000_base_structure.sql

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ CREATE TABLE IF NOT EXISTS `blocks` (
4343
`accounted` tinyint(1) NOT NULL DEFAULT '0',
4444
`account_id` int(255) unsigned DEFAULT NULL,
4545
`worker_name` varchar(50) DEFAULT 'unknown',
46-
`shares` bigint(30) unsigned DEFAULT NULL,
46+
`shares` double unsigned DEFAULT NULL,
4747
`share_id` bigint(30) DEFAULT NULL,
4848
PRIMARY KEY (`id`),
4949
UNIQUE KEY `height` (`height`,`blockhash`),

templates/bootstrap/dashboard/blocks/default.tpl

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -26,8 +26,8 @@
2626
<td class="text-right">{$BLOCKSFOUND[block].time|date_format:$GLOBAL.config.date}</td>
2727
<td class="text-right">{$BLOCKSFOUND[block].difficulty|number_format:"4"}</td>
2828
<td class="text-right">{$BLOCKSFOUND[block].amount|number_format:"2"}</td>
29-
<td class="text-right">{$BLOCKSFOUND[block].estshares|number_format}</td>
30-
<td class="text-right">{$BLOCKSFOUND[block].shares|number_format}</td>
29+
<td class="text-right">{$BLOCKSFOUND[block].estshares|number_format:$GLOBAL.config.sharediffprecision}</td>
30+
<td class="text-right">{$BLOCKSFOUND[block].shares|number_format:$GLOBAL.config.sharediffprecision}</td>
3131
<td class="text-right">
3232
{math assign="percentage" equation="shares / estshares * 100" shares=$BLOCKSFOUND[block].shares|default:"0" estshares=$BLOCKSFOUND[block].estshares}
3333
<font color="{if ($percentage <= 100)}green{else}red{/if}">{$percentage|number_format:"2"}</font>
@@ -46,4 +46,4 @@
4646
{/if}
4747
</div>
4848
</div>
49-
{/if}
49+
{/if}

templates/bootstrap/dashboard/js/api.tpl

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ $(document).ready(function(){
4343
4444
// Load initial sparkline values
4545
var storedPersonalHashrate = [ null, null, null, null, null, null, null, null, null, null, null, null, {/literal}{$GLOBAL.userdata.hashrate|round:"2"}{literal} ];
46-
var storedPersonalSharerate = [ null, null, null, null, null, null, null, null, null, null, null, null, {/literal}{$GLOBAL.userdata.sharerate|round:"2"}{literal} ];
46+
var storedPersonalSharerate = [ null, null, null, null, null, null, null, null, null, null, null, null, {/literal}{$GLOBAL.userdata.sharerate|round:$GLOBAL.config.sharediffprecision}{literal} ];
4747
var storedPoolHashrate = [ null, null, null, null, null, null, null, null, null, null, null, null, {/literal}{$GLOBAL.hashrate|round:"2"}{literal} ];
4848
var storedNetHashrate = [ null, null, null, null, null, null, null, null, null, null, null, null, {/literal}{$GLOBAL.nethashrate|round:"2"}{literal} ];
4949
var storedPoolWorkers = [ null, null, null, null, null, null, null, null, null, null, null, null, {/literal}{$GLOBAL.workers}{literal} ];
@@ -89,7 +89,7 @@ $(document).ready(function(){
8989
storedPersonalHashrate.shift();
9090
storedPersonalHashrate.push(parseFloat(data.getdashboarddata.data.personal.hashrate).toFixed(2))
9191
storedPersonalSharerate.shift();
92-
storedPersonalSharerate.push(parseFloat(data.getdashboarddata.data.personal.sharerate).toFixed(2))
92+
storedPersonalSharerate.push(parseFloat(data.getdashboarddata.data.personal.sharerate).toFixed({/literal}{$GLOBAL.config.sharediffprecision}{literal}))
9393
storedPoolHashrate.shift();
9494
storedPoolHashrate.push(parseFloat(data.getdashboarddata.data.pool.hashrate).toFixed(2))
9595
storedNetHashrate.shift();
@@ -122,7 +122,7 @@ $(document).ready(function(){
122122
} else {
123123
$('#b-nethashrate').html('n/a');
124124
}
125-
$('#b-sharerate').html((parseFloat(data.getdashboarddata.data.personal.sharerate).toFixed(2)));
125+
$('#b-sharerate').html((parseFloat(data.getdashboarddata.data.personal.sharerate).toFixed({/literal}{$GLOBAL.config.sharediffprecision}{literal})));
126126
$('#b-yvalid').html(number_format(data.getdashboarddata.data.personal.shares.valid, {/literal}{$GLOBAL.config.sharediffprecision}{literal}));
127127
$('#b-yivalid').html(number_format(data.getdashboarddata.data.personal.shares.invalid, {/literal}{$GLOBAL.config.sharediffprecision}{literal}));
128128
if ( data.getdashboarddata.data.personal.shares.valid > 0 ) {

templates/bootstrap/dashboard/overview/_with_price_graph.tpl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@
4343
<div class="circle-tile-description text-faded">
4444
<p class="h5 up-more">My Sharerate</p>
4545
<div class="circle-tile-number text-faded up">
46-
<span class="overview" id="b-sharerate">{$GLOBAL.userdata.sharerate|number_format:"2"}</span>
46+
<span class="overview" id="b-sharerate">{$GLOBAL.userdata.sharerate|number_format:$GLOBAL.config.sharediffprecision}</span>
4747
<span class="overview-mhs"> S/s</span>
4848
<br>
4949
<span class="personal-sharerate-bar spark-18"></span>

templates/bootstrap/dashboard/overview/_without_price_graph.tpl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@
4343
<div class="circle-tile-description text-faded">
4444
<p class="h5 up-more">My Sharerate</p>
4545
<div class="circle-tile-number text-faded up">
46-
<span class="overview" id="b-sharerate">{$GLOBAL.userdata.sharerate|number_format:"2"}</span>
46+
<span class="overview" id="b-sharerate">{$GLOBAL.userdata.sharerate|number_format:$GLOBAL.config.sharediffprecision}</span>
4747
<span class="overview-mhs"> S/s</span>
4848
<br>
4949
<span class="personal-sharerate-bar spark-18"></span>

templates/bootstrap/dashboard/round_statistics/prop/round.tpl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@
7070
<p class="h5" id="b-nextdiff">{if $GLOBAL.nethashrate > 0}{$NETWORK.EstNextDifficulty|number_format:"8"}{else}n/a{/if}</p>
7171
</div>
7272
<div class="circle-tile-number text-faded">
73-
<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>
73+
<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>
7474
</div>
7575
</div>
7676
</div>

0 commit comments

Comments
 (0)