Merge pull request #821 from TheSerapher/issue-819
[FIX] Display issues on SHA coins
This commit is contained in:
commit
d2d7ee6796
@ -759,7 +759,7 @@ class Statistics {
|
||||
SELECT
|
||||
IFNULL(COUNT(id), 0) as count,
|
||||
IFNULL(AVG(difficulty), 0) as average,
|
||||
IFNULL(ROUND(SUM((difficulty * 65536) / POW(2, (" . $this->config['difficulty'] . " -16))), 0), 0) AS expected,
|
||||
IFNULL(ROUND(SUM((POW(2, ( 32 - " . $this->config['target_bits'] . " )) * difficulty) / POW(2, (" . $this->config['difficulty'] . " -16))), 0), 0) AS expected,
|
||||
IFNULL(ROUND(SUM(shares)), 0) as shares,
|
||||
IFNULL(SUM(amount), 0) as rewards
|
||||
FROM " . $this->block->getTableName() . "
|
||||
@ -772,6 +772,14 @@ class Statistics {
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Caclulate estimated shares based on network difficulty and pool difficulty
|
||||
* @param dDiff double Network difficulty
|
||||
* @return shares integer Share count
|
||||
**/
|
||||
public function getEstimatedShares($dDiff) {
|
||||
return round((POW(2, (32 - $this->config['target_bits'])) * $dDiff) / pow(2, ($this->config['difficulty'] - 16)));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
@ -67,7 +67,7 @@ class Worker extends Base {
|
||||
* @param id int Worker ID
|
||||
* @return mixed array Worker details
|
||||
**/
|
||||
public function getWorker($id) {
|
||||
public function getWorker($id, $interval=600) {
|
||||
$this->debug->append("STA " . __METHOD__, 4);
|
||||
$stmt = $this->mysqli->prepare("
|
||||
SELECT id, username, password, monitor,
|
||||
@ -75,34 +75,35 @@ class Worker extends Base {
|
||||
( SELECT COUNT(id) FROM " . $this->share->getArchiveTableName() . " WHERE username = w.username AND time > DATE_SUB(now(), INTERVAL 10 MINUTE)) AS count_all_archive,
|
||||
(
|
||||
SELECT
|
||||
IFNULL(IF(our_result='Y', ROUND(SUM(IF(difficulty=0, pow(2, (" . $this->config['difficulty'] . " - 16)), difficulty)) * POW(2, " . $this->config['target_bits'] . ") / 600 / 1000), 0), 0) AS hashrate
|
||||
IFNULL(IF(our_result='Y', ROUND(SUM(IF(difficulty=0, pow(2, (" . $this->config['difficulty'] . " - 16)), difficulty)) * POW(2, " . $this->config['target_bits'] . ") / ? / 1000), 0), 0) AS hashrate
|
||||
FROM " . $this->share->getTableName() . "
|
||||
WHERE
|
||||
username = w.username
|
||||
AND time > DATE_SUB(now(), INTERVAL 10 MINUTE)
|
||||
AND time > DATE_SUB(now(), INTERVAL ? SECOND)
|
||||
) + (
|
||||
SELECT
|
||||
IFNULL(IF(our_result='Y', ROUND(SUM(IF(difficulty=0, pow(2, (" . $this->config['difficulty'] . " - 16)), difficulty)) * POW(2, " . $this->config['target_bits'] . ") / 600 / 1000), 0), 0) AS hashrate
|
||||
IFNULL(IF(our_result='Y', ROUND(SUM(IF(difficulty=0, pow(2, (" . $this->config['difficulty'] . " - 16)), difficulty)) * POW(2, " . $this->config['target_bits'] . ") / ? / 1000), 0), 0) AS hashrate
|
||||
FROM " . $this->share->getArchiveTableName() . "
|
||||
WHERE
|
||||
username = w.username
|
||||
AND time > DATE_SUB(now(), INTERVAL 10 MINUTE)
|
||||
AND time > DATE_SUB(now(), INTERVAL ? SECOND)
|
||||
) AS hashrate,
|
||||
(
|
||||
SELECT IFNULL(ROUND(SUM(IF(difficulty=0, pow(2, (" . $this->config['difficulty'] . " - 16)), difficulty)) / count_all, 2), 0)
|
||||
FROM " . $this->share->getTableName() . "
|
||||
WHERE username = w.username AND time > DATE_SUB(now(), INTERVAL 10 MINUTE)
|
||||
WHERE username = w.username AND time > DATE_SUB(now(), INTERVAL ? SECOND)
|
||||
) + (
|
||||
SELECT IFNULL(ROUND(SUM(IF(difficulty=0, pow(2, (" . $this->config['difficulty'] . " - 16)), difficulty)) / count_all_archive, 2), 0)
|
||||
FROM " . $this->share->getArchiveTableName() . "
|
||||
WHERE username = w.username AND time > DATE_SUB(now(), INTERVAL 10 MINUTE)
|
||||
WHERE username = w.username AND time > DATE_SUB(now(), INTERVAL ? SECOND)
|
||||
) AS difficulty
|
||||
FROM $this->table AS w
|
||||
WHERE id = ?
|
||||
");
|
||||
if ($this->checkStmt($stmt) && $stmt->bind_param('i', $id) && $stmt->execute() && $result = $stmt->get_result())
|
||||
if ($this->checkStmt($stmt) && $stmt->bind_param('iiiiiii', $interval, $interval, $interval, $interval, $interval, $interval, $id) && $stmt->execute() && $result = $stmt->get_result())
|
||||
return $result->fetch_assoc();
|
||||
// Catchall
|
||||
$this->serErrorMessage('Failed fetching worker details: '. $this->mysqli->error());
|
||||
return false;
|
||||
}
|
||||
|
||||
@ -119,14 +120,14 @@ class Worker extends Base {
|
||||
( SELECT COUNT(id) FROM " . $this->share->getArchiveTableName() . " WHERE username = w.username AND time > DATE_SUB(now(), INTERVAL ? SECOND)) AS count_all_archive,
|
||||
(
|
||||
SELECT
|
||||
IFNULL(IF(our_result='Y', ROUND(SUM(IF(difficulty=0, pow(2, (" . $this->config['difficulty'] . " - 16)), difficulty)) * 65536 / ? / 1000), 0), 0) AS hashrate
|
||||
IFNULL(IF(our_result='Y', ROUND(SUM(IF(difficulty=0, pow(2, (" . $this->config['difficulty'] . " - 16)), difficulty)) * POW(2, " . $this->config['target_bits'] . ") / ? / 1000), 0), 0) AS hashrate
|
||||
FROM " . $this->share->getTableName() . "
|
||||
WHERE
|
||||
username = w.username
|
||||
AND time > DATE_SUB(now(), INTERVAL ? SECOND)
|
||||
) + (
|
||||
SELECT
|
||||
IFNULL(IF(our_result='Y', ROUND(SUM(IF(difficulty=0, pow(2, (" . $this->config['difficulty'] . " - 16)), difficulty)) * 65536 / ? / 1000), 0), 0) AS hashrate
|
||||
IFNULL(IF(our_result='Y', ROUND(SUM(IF(difficulty=0, pow(2, (" . $this->config['difficulty'] . " - 16)), difficulty)) * POW(2, " . $this->config['target_bits'] . ") / ? / 1000), 0), 0) AS hashrate
|
||||
FROM " . $this->share->getArchiveTableName() . "
|
||||
WHERE
|
||||
username = w.username
|
||||
|
||||
@ -80,7 +80,7 @@ $aWorkers = $worker->getWorkers($user_id, $interval);
|
||||
$aPrice = $setting->getValue('price');
|
||||
|
||||
// Round progress
|
||||
$iEstShares = round((65536 * $dDifficulty) / pow(2, ($config['difficulty'] - 16)));
|
||||
$iEstShares = $statistics->getEstimatedShares($dDifficulty);
|
||||
$dEstPercent = round(100 / $iEstShares * $aRoundShares['valid'], 2);
|
||||
|
||||
// Output JSON format
|
||||
|
||||
@ -44,7 +44,7 @@ if ($iTotalRoundShares > 0) {
|
||||
}
|
||||
|
||||
// Round progress
|
||||
$iEstShares = round((65536 * $dDifficulty) / pow(2, ($config['difficulty'] - 16)));
|
||||
$iEstShares = $statistics->getEstimatedShares($dDifficulty);
|
||||
$dEstPercent = round(100 / $iEstShares * $aRoundShares['valid'], 2);
|
||||
|
||||
// Output JSON format
|
||||
|
||||
@ -65,6 +65,7 @@ $aGlobal = array(
|
||||
'price' => $setting->getValue('price'),
|
||||
'disable_mp' => $setting->getValue('disable_mp'),
|
||||
'config' => array(
|
||||
'target_bits' => $config['target_bits'],
|
||||
'accounts' => $config['accounts'],
|
||||
'disable_invitations' => $setting->getValue('disable_invitations'),
|
||||
'disable_notifications' => $setting->getValue('disable_notifications'),
|
||||
|
||||
@ -131,7 +131,7 @@ target and network difficulty and assuming a zero variance scenario.
|
||||
<td class="right">{$BLOCKSFOUND[block].shares|number_format}</td>
|
||||
<td class="right">
|
||||
{math assign="percentage" equation="shares / estshares * 100" shares=$BLOCKSFOUND[block].shares estshares=$BLOCKSFOUND[block].estshares}
|
||||
{assign var="totalpercentage" value=$totalpercentage+$percentage}
|
||||
{assign var="totalpercentage" value=$totalpercentage+$percentage}
|
||||
<font color="{if ($percentage <= 100)}green{else}red{/if}">{$percentage|number_format:"2"}</font>
|
||||
</td>
|
||||
</tr>
|
||||
|
||||
@ -48,7 +48,7 @@
|
||||
</tr>
|
||||
<tr>
|
||||
<td class="leftheader">Est. Shares this Round</td>
|
||||
{assign var=estshares value=(65536 * $DIFFICULTY) / pow(2, ($GLOBAL.config.targetdiff - 16))}
|
||||
{assign var=estshares value=(pow(2, (32 - $GLOBAL.config.target_bits)) * $DIFFICULTY) / pow(2, ($GLOBAL.config.targetdiff - 16))}
|
||||
<td>{$estshares|number_format:"0"} <font size="1">(done: {(100 / $estshares * $GLOBAL.roundshares.valid)|number_format:"2"} %)</td>
|
||||
</tr>
|
||||
<tr>
|
||||
|
||||
@ -13,7 +13,7 @@
|
||||
<tr>
|
||||
<th scope="row">Expected</th>
|
||||
{section block $BLOCKSFOUND step=-1}
|
||||
<td>{round(pow(2,32 - $GLOBAL.config.targetdiff) * $BLOCKSFOUND[block].difficulty)}</td>
|
||||
<td>{$BLOCKSFOUND[block].estshares}</td>
|
||||
{/section}
|
||||
</tr>
|
||||
<tr>
|
||||
|
||||
Loading…
Reference in New Issue
Block a user