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
This commit is contained in:
Sebastian Grewe 2013-07-07 22:24:52 +02:00
parent 6dc795fd77
commit 6193604598

View File

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