From 8669f987dca490fc1c6fdb30dc7b639bb970ab15 Mon Sep 17 00:00:00 2001 From: Sebastian Grewe Date: Fri, 10 May 2013 22:37:24 +0200 Subject: [PATCH] adding new cronjob to accumulate valid and invalid shares for each user between a timestamp of a block and the previous block to it --- cronjobs/sharecounter.php | 49 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 49 insertions(+) create mode 100644 cronjobs/sharecounter.php diff --git a/cronjobs/sharecounter.php b/cronjobs/sharecounter.php new file mode 100644 index 00000000..0a5ce6fe --- /dev/null +++ b/cronjobs/sharecounter.php @@ -0,0 +1,49 @@ +getAll('ASC'); + +foreach ($aAllBlocks as $iIndex => $aBlock) { + if (!$aBlock['accounted']) { + $iPrevBlockTime = $aAllBlocks[$iIndex - 1]['time']; + if ($iPrevBlockTime) { + echo "Found a previous block with timestamp: $iPrevBlockTime\n"; + } + $aAccountShares = $share->getSharesForAccountsByTimeframe($aBlock['time'], $iPrevBlockTime); + $strFinder = $share->getFinderByTimeframe($aBlock['time'], $iPrevBlockTime); + echo "Block Information:\n"; + echo "Height\tTime\t\tFinder\n\n"; + echo $aBlock['height'] . "\t" . $aBlock['time'] . "\t" . $strFinder . "\n"; + echo "\nShares details:\n\n"; + echo "ID\tUsername\tValid\tInvalid\n\n"; + foreach ($aAccountShares as $aData) { + echo $aData['id'] . "\t" . $aData['username'] . "\t" . $aData['valid'] . "\t" . $aData['invalid'] . "\n"; + } + echo "\n"; + // TODO: Find all shares for this blocks round and account the users + // propotional to their shares for this block + } + // TODO: We have accounted all shares for a block so mark it accounted + // and delete all the shares we just accounted for. +}