From 9536e7c19320a1ffaece21b82af7284852ff6208 Mon Sep 17 00:00:00 2001 From: Sebastian Grewe Date: Tue, 14 May 2013 17:58:10 +0200 Subject: [PATCH] fixing pps payout, getRoundShares system MUST be search by ID or round shares are NOT calculated properly --- cronjobs/pps_payout.php | 3 +-- public/include/classes/share.class.php | 22 ++++++++-------------- 2 files changed, 9 insertions(+), 16 deletions(-) diff --git a/cronjobs/pps_payout.php b/cronjobs/pps_payout.php index d840db8f..1b91e73d 100644 --- a/cronjobs/pps_payout.php +++ b/cronjobs/pps_payout.php @@ -43,8 +43,7 @@ foreach ($aAllBlocks as $iIndex => $aBlock) { continue; } $aAccountShares = $share->getSharesForAccounts($share->getLastUpstreamId(), $iCurrentUpstreamId); - $aRoundShares = $share->getRoundShares($share->getLastUpstreamId(), $iCurrentUpstreamId); - $iRoundShares = $aRoundShares['valid']; + $iRoundShares = $share->getRoundShares($share->getLastUpstreamId(), $iCurrentUpstreamId); verbose("ID\tHeight\tTime\t\tShares\tFinder\t\tShare ID\tPrev Share\tStatus\n"); verbose($aBlock['id'] . "\t" . $aBlock['height'] . "\t" . $aBlock['time'] . "\t" . $iRoundShares . "\t" . $share->getUpstreamFinder() . "\t" . $share->getUpstreamId() . "\t\t" . $share->getLastUpstreamId()); if (empty($aAccountShares)) { diff --git a/public/include/classes/share.class.php b/public/include/classes/share.class.php index 5d8fc276..f9e7c869 100644 --- a/public/include/classes/share.class.php +++ b/public/include/classes/share.class.php @@ -34,25 +34,19 @@ class Share { return $this->table; } - public function getRoundShares() { - $stmt = $this->mysqli->prepare(" - SELECT - ( SELECT IFNULL(count(id), 0) - FROM $this->table - WHERE UNIX_TIMESTAMP(time) >IFNULL((SELECT MAX(time) FROM blocks),0) - AND our_result = 'Y' ) as valid, - ( SELECT IFNULL(count(id), 0) + public function getRoundShares($previous_upstream=0, $current_upstream) { + $stmt = $this->mysqli->prepare("SELECT + count(id) as total FROM $this->table - WHERE UNIX_TIMESTAMP(time) >IFNULL((SELECT MAX(time) FROM blocks),0) - AND our_result = 'N' ) as invalid - "); - echo $this->mysqli->error; + WHERE our_result = 'Y' + AND id BETWEEN ? AND ? + "); if ($this->checkStmt($stmt)) { - + $stmt->bind_param('ii', $previous_upstream, $current_upstream); $stmt->execute(); $result = $stmt->get_result(); $stmt->close(); - return $result->fetch_assoc(); + return $result->fetch_object()->total; } return false; }