Revert "adjusting pplns target to baseline shares"

* Shares are already baselined when calculating rounds

This reverts commit c9a8f8dc65.
This commit is contained in:
Sebastian Grewe 2013-08-22 14:51:30 +02:00
parent c9a8f8dc65
commit 2d27132725
2 changed files with 4 additions and 51 deletions

View File

@ -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

View File

@ -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
**/