From 2d271327252f8a623c883024ef951fe82a2f0c03 Mon Sep 17 00:00:00 2001 From: Sebastian Grewe Date: Thu, 22 Aug 2013 14:51:30 +0200 Subject: [PATCH] Revert "adjusting pplns target to baseline shares" * Shares are already baselined when calculating rounds This reverts commit c9a8f8dc65f06fbc3d14695716ff511a58df6c2a. --- cronjobs/pplns_payout.php | 13 ++------ public/include/classes/share.class.php | 42 +------------------------- 2 files changed, 4 insertions(+), 51 deletions(-) diff --git a/cronjobs/pplns_payout.php b/cronjobs/pplns_payout.php index 6d718870..c71f5659 100755 --- a/cronjobs/pplns_payout.php +++ b/cronjobs/pplns_payout.php @@ -45,12 +45,9 @@ foreach ($aAllBlocks as $iIndex => $aBlock) { if ($config['pplns']['shares']['type'] == 'blockavg' && $block->getBlockCount() > 0) { $pplns_target = round($block->getAvgBlockShares($config['pplns']['blockavg']['blockcount'])); } else { - $pplns_target = $config['pplns']['shares']['default']; + $pplns_target = $config['pplns']['shares']['default'] ; } - // We use baseline shares, so we have to calculate back to diff shares - $pplns_target = $pplns_target * pow(2, ($config['difficulty'] - 16)); - if (!$aBlock['accounted']) { $iPreviousShareId = @$aAllBlocks[$iIndex - 1]['share_id'] ? $aAllBlocks[$iIndex - 1]['share_id'] : 0; $iCurrentUpstreamId = $aBlock['share_id']; @@ -68,8 +65,7 @@ foreach ($aAllBlocks as $iIndex => $aBlock) { if ($iRoundShares >= $pplns_target) { $log->logDebug("Matching or exceeding PPLNS target of $pplns_target with $iRoundShares"); - $iMinimumShareId = $share->getMinimumShareId($pplns_target, $aBlock['share_id']); - $aAccountShares = $share->getSharesForAccounts($iMinimumShareId, $aBlock['share_id']); + $aAccountShares = $share->getSharesForAccounts($aBlock['share_id'] - $pplns_target, $aBlock['share_id']); if (empty($aAccountShares)) { $log->logFatal("No shares found for this block, aborted! Block Height : " . $aBlock['height']); $monitoring->setStatus($cron_name . "_active", "yesno", 0); @@ -77,11 +73,8 @@ foreach ($aAllBlocks as $iIndex => $aBlock) { $monitoring->setStatus($cron_name . "_status", "okerror", 1); exit(1); } - foreach($aAccountShares as $key => $aData) { - $iNewRoundShares += $aData['valid']; - } $log->logInfo('Adjusting round target to PPLNS target ' . $pplns_target); - $iRoundShares = $iNewRoundShares; + $iRoundShares = $pplns_target; } else { $log->logDebug("Not able to match PPLNS target of $pplns_target with $iRoundShares"); // We need to fill up with archived shares diff --git a/public/include/classes/share.class.php b/public/include/classes/share.class.php index 85a005de..d3b88759 100644 --- a/public/include/classes/share.class.php +++ b/public/include/classes/share.class.php @@ -130,7 +130,7 @@ class Share { * return array data Returns an array with usernames as keys for easy access **/ function getArchiveShares($iCount) { - $iMinId = $this->getMinArchiveShareId($iCount); + $iMinId = $this->getMaxArchiveShareId() - $iCount; $iMaxId = $this->getMaxArchiveShareId(); $stmt = $this->mysqli->prepare(" SELECT @@ -307,46 +307,6 @@ class Share { return false; } - /** - * Fetch the lowest needed share ID from shares - **/ - function getMinimumShareId($iCount, $current_upstream) { - $stmt = $this->mysqli->prepare(" - SELECT MIN(b.id) AS id FROM - ( - SELECT id, @total := @total + IF(difficulty=0, POW(2, (" . $this->config['difficulty'] . " - 16)), difficulty) AS total - FROM $this->table, (SELECT @total := 0) AS a - WHERE our_result = 'Y' - AND id <= ? AND @total < ? - ORDER BY id DESC - ) AS b - WHERE total <= ? - "); - if ($this->checkStmt($stmt) && $stmt->bind_param('iii', $current_upstream, $iCount, $iCount) && $stmt->execute() && $result = $stmt->get_result()) - return $result->fetch_object()->id; - return false; - } - - /** - * Fetch the lowest needed share ID from archive - **/ - function getMinArchiveShareId($iCount) { - $stmt = $this->mysqli->prepare(" - SELECT MIN(b.share_id) AS share_id FROM - ( - SELECT share_id, @total := @total + IF(difficulty=0, pow(2, (" . $this->config['difficulty'] . " - 16)), difficulty) AS total - FROM $this->tableArchive, (SELECT @total := 0) AS a - WHERE our_result = 'Y' - AND @total < ? - ORDER BY share_id DESC - ) AS b - WHERE total <= ? - "); - if ($this->checkStmt($stmt) && $stmt->bind_param('ii', $iCount, $iCount) && $stmt->execute() && $result = $stmt->get_result()) - return $result->fetch_object()->share_id; - return false; - } - /** * Helper function **/