Skip to content

Commit

Permalink
Merge pull request MPOS#2727 from r4sas/lowdiff-shares
Browse files Browse the repository at this point in the history
implement low-diff shares counting (#2718 #2726)
  • Loading branch information
TheSerapher authored May 11, 2018
2 parents 3ddf6cb + 8cfc43e commit 363e2be
Show file tree
Hide file tree
Showing 5 changed files with 10 additions and 10 deletions.
4 changes: 2 additions & 2 deletions include/classes/statistics.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -203,7 +203,7 @@ public function getBlocksSolvedbyWorker($account_id, $limit=25) {
public function updateShareStatistics($aStats, $iBlockId) {
$this->debug->append("STA " . __METHOD__, 4);
$stmt = $this->mysqli->prepare("INSERT INTO $this->table (account_id, valid, invalid, block_id) VALUES (?, ?, ?, ?)");
if ($this->checkStmt($stmt) && $stmt->bind_param('iiii', $aStats['id'], $aStats['valid'], $aStats['invalid'], $iBlockId) && $stmt->execute()) return true;
if ($this->checkStmt($stmt) && $stmt->bind_param('iddi', $aStats['id'], $aStats['valid'], $aStats['invalid'], $iBlockId) && $stmt->execute()) return true;
return $this->sqlError();
}

Expand All @@ -213,7 +213,7 @@ public function updateShareStatistics($aStats, $iBlockId) {
public function insertPPLNSStatistics($aStats, $iBlockId) {
$this->debug->append("STA " . __METHOD__, 4);
$stmt = $this->mysqli->prepare("INSERT INTO $this->table (account_id, valid, invalid, pplns_valid, pplns_invalid, block_id) VALUES (?, ?, ?, ?, ?, ?)");
if ($this->checkStmt($stmt) && $stmt->bind_param('iiiiii', $aStats['id'], $aStats['valid'], $aStats['invalid'], $aStats['pplns_valid'], $aStats['pplns_invalid'], $iBlockId) && $stmt->execute()) return true;
if ($this->checkStmt($stmt) && $stmt->bind_param('iddddi', $aStats['id'], $aStats['valid'], $aStats['invalid'], $aStats['pplns_valid'], $aStats['pplns_invalid'], $iBlockId) && $stmt->execute()) return true;
return $this->sqlError();
}

Expand Down
8 changes: 4 additions & 4 deletions sql/000_base_structure.sql
Original file line number Diff line number Diff line change
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` bigint(20) NOT NULL DEFAULT '0',
`invalid` bigint(20) NOT NULL DEFAULT '0',
`pplns_valid` bigint(20) NOT NULL DEFAULT '0',
`pplns_invalid` bigint(20) NOT NULL DEFAULT '0',
`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',
PRIMARY KEY (`id`),
KEY `account_id` (`account_id`),
KEY `block_id` (`block_id`)
Expand Down
4 changes: 2 additions & 2 deletions templates/bootstrap/statistics/round/pplns_transactions.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,9 @@
{section txs $ROUNDTRANSACTIONS}
<tr{if $GLOBAL.userdata.username|default:"" == $ROUNDTRANSACTIONS[txs].username}{assign var=listed value=1} style="background-color:#99EB99;"{else}{/if}>
<td>{if $ROUNDTRANSACTIONS[txs].is_anonymous|default:"0" == 1 && $GLOBAL.userdata.is_admin|default:"0" == 0}anonymous{else}{$ROUNDTRANSACTIONS[txs].username|default:"unknown"|escape}{/if}</td>
<td>{$ROUNDSHARES[$ROUNDTRANSACTIONS[txs].uid].valid|number_format|default:0}</td>
<td>{$ROUNDSHARES[$ROUNDTRANSACTIONS[txs].uid].valid|number_format:$GLOBAL.config.sharediffprecision|default:"0"}</td>
<td>{if $ROUNDSHARES[$ROUNDTRANSACTIONS[txs].uid].valid|default:"0" > 0 }{(( 100 / $BLOCKDETAILS.shares) * $ROUNDSHARES[$ROUNDTRANSACTIONS[txs].uid].valid)|number_format:"2"}{else}0.00{/if}</td>
<td>{$PPLNSROUNDSHARES[txs].pplns_valid|number_format|default:"0"}</td>
<td>{$PPLNSROUNDSHARES[txs].pplns_valid|number_format:$GLOBAL.config.sharediffprecision|default:"0"}</td>
<td>{if $PPLNSROUNDSHARES[txs].pplns_valid|default:"0" > 0 }{(( 100 / $PPLNSSHARES) * $PPLNSROUNDSHARES[txs].pplns_valid)|number_format:"2"|default:"0"}{else}0{/if}</td>
<td>{if $ROUNDSHARES[$ROUNDTRANSACTIONS[txs].uid].valid|default:"0" > 0 && $PPLNSROUNDSHARES[txs].pplns_valid|default:"0" > 0}{math assign="percentage1" equation=(100 / ((( 100 / $BLOCKDETAILS.shares) * $ROUNDSHARES[$ROUNDTRANSACTIONS[txs].uid].valid) / (( 100 / $PPLNSSHARES) * $PPLNSROUNDSHARES[txs].pplns_valid)))}{else if $PPLNSROUNDSHARES[txs].pplns_valid|default:"0" == 0}{assign var=percentage1 value=0}{else}{assign var=percentage1 value=100}{/if}
<font color="{if ($percentage1 >= 100)}green{else}red{/if}">{$percentage1|number_format:"2"}</font></b></td>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
<tr{if $GLOBAL.userdata.username|default:"" == $ROUNDTRANSACTIONS[txs].username} style="background-color:#99EB99;"{else}{/if}>
<td>{if $ROUNDTRANSACTIONS[txs].is_anonymous|default:"0" == 1 && $GLOBAL.userdata.is_admin|default:"0" == 0}anonymous{else}{$ROUNDTRANSACTIONS[txs].username|default:"unknown"|escape}{/if}</td>
<td>{$ROUNDTRANSACTIONS[txs].type|default:""}</td>
<td>{$ROUNDSHARES[$ROUNDTRANSACTIONS[txs].uid].valid|number_format}</td>
<td>{$ROUNDSHARES[$ROUNDTRANSACTIONS[txs].uid].valid|number_format:$GLOBAL.config.sharediffprecision|default:"0"}</td>
<td>{(( 100 / $BLOCKDETAILS.shares) * $ROUNDSHARES[$ROUNDTRANSACTIONS[txs].uid].valid)|default:"0"|number_format:"2"}</td>
<td>{$ROUNDTRANSACTIONS[txs].amount|default:"0"|number_format:"8"}</td>
</tr>
Expand Down
2 changes: 1 addition & 1 deletion upgrade/definitions/1.0.2_to_1.0.3.inc.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ function run_103() {
// Upgrade specific variables
$aSql[] = "UPDATE `statistics_shares` SET `valid` = '0' WHERE `valid` IS NULL;";
$aSql[] = "UPDATE `statistics_shares` SET `pplns_valid` = '0' WHERE `pplns_valid` IS NULL;";
$aSql[] = "ALTER TABLE `statistics_shares` CHANGE `valid` `valid` BIGINT(20) NOT NULL DEFAULT '0', CHANGE `pplns_valid` `pplns_valid` BIGINT(20) NOT NULL DEFAULT '0';";
$aSql[] = "ALTER TABLE `statistics_shares` CHANGE `valid` `valid` FLOAT NOT NULL DEFAULT '0', CHANGE `invalid` `invalid` FLOAT NOT NULL DEFAULT '0', CHANGE `pplns_valid` `pplns_valid` FLOAT NOT NULL DEFAULT '0', CHANGE `pplns_invalid` `pplns_invalid` FLOAT NOT NULL DEFAULT '0';";
$aSql[] = "UPDATE " . $setting->getTableName() . " SET value = '" . $db_version_new . "' WHERE name = 'DB_VERSION';";

if ($db_version_now == $db_version_old && version_compare($db_version_now, DB_VERSION, '<')) {
Expand Down

0 comments on commit 363e2be

Please sign in to comment.