Ensure no old blocks shares are counter for new ones
When finding more than a single block between runs it added shares to a new block from a previous one. Properly fetch the last highest share ID from the database prior to scanning for shares assigned to a block. Fixes #124
This commit is contained in:
parent
85d81f821f
commit
4691e077e2
@ -87,7 +87,11 @@ foreach ($aAllBlocks as $iIndex => $aBlock) {
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
// Fetch share information
|
// Fetch share information
|
||||||
$iPreviousShareId = @$aAllBlocks[$iIndex - 1]['share_id'] ? $aAllBlocks[$iIndex - 1]['share_id'] : 0;
|
if (!$iPreviousShareId = $block->getLastShareId()) {
|
||||||
|
$iPreviousShareId = 0;
|
||||||
|
verbose("\nUnable to find highest share ID found so far\n");
|
||||||
|
verbose("If this is your first block, this is normal\n\n");
|
||||||
|
}
|
||||||
$iRoundShares = $share->getRoundShares($iPreviousShareId, $iCurrentUpstreamId);
|
$iRoundShares = $share->getRoundShares($iPreviousShareId, $iCurrentUpstreamId);
|
||||||
|
|
||||||
// Store new information
|
// Store new information
|
||||||
|
|||||||
@ -43,6 +43,18 @@ class Block {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get our last, highest share ID inserted for a block
|
||||||
|
* @param none
|
||||||
|
* @return int data Share ID
|
||||||
|
**/
|
||||||
|
public function getLastShareId() {
|
||||||
|
$stmt = $this->mysqli->prepare("SELECT MAX(share_id) AS share_id FROM $this->table LIMIT 1");
|
||||||
|
if ($this->checkStmt($stmt) && $stmt->execute() && $result = $stmt->get_result())
|
||||||
|
return $result->fetch_object()->share_id;
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Fetch all unaccounted blocks
|
* Fetch all unaccounted blocks
|
||||||
* @param order string Sort order, default ASC
|
* @param order string Sort order, default ASC
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user