From 6193604598f084e66d53f96980bb475aa70a5c2d Mon Sep 17 00:00:00 2001 From: Sebastian Grewe Date: Sun, 7 Jul 2013 22:24:52 +0200 Subject: [PATCH] Fallback call if upstream share not found properly Implemented a fallback method in case no upstream share can be found for a block. This will result in same strange behaviour especially if a later block has properly added a valid share and this will be used for a previous block. At least now even the last block will be properly found and marked as discovered by a user, even though no actual upstream share was involved in this. This is a dirty workaround for pools having payout issues. After all blocks are processed and assuming upstream shares continue to work as expected, this will *skip* broken blocks/shares. Workaround fix for #392 --- public/include/classes/share.class.php | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/public/include/classes/share.class.php b/public/include/classes/share.class.php index 6653814a..5e4db85e 100644 --- a/public/include/classes/share.class.php +++ b/public/include/classes/share.class.php @@ -191,6 +191,20 @@ class Share { if (!empty($this->oUpstream->account) && is_int($this->oUpstream->id)) return true; } + // First attempt failed, we do a fallback with any share available for now + $stmt = $this->mysqli->prepare(" + SELECT + SUBSTRING_INDEX( `username` , '.', 1 ) AS account, id + FROM $this->table + WHERE our_result = 'Y' + AND id > ? + AND UNIX_TIMESTAMP(time) >= ? + ORDER BY id ASC LIMIT 1"); + if ($this->checkStmt($stmt) && $stmt->bind_param('ii', $last, $time) && $stmt->execute() && $result = $stmt->get_result()) { + $this->oUpstream = $result->fetch_object(); + if (!empty($this->oUpstream->account) && is_int($this->oUpstream->id)) + return true; + } // Catchall return false; }