Skip to content

Commit 64205dd

Browse files
committed
[MERGE] Fix merge conflict with NEXT
2 parents 52db8bc + db89768 commit 64205dd

31 files changed

+266
-85
lines changed

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,7 @@ The following feature have been implemented so far:
8080

8181
* Fully re-written GUI with [Smarty][2] templates
8282
* Mobile WebUI
83+
* **SOON** VARDIFF Support
8384
* Reward Systems
8485
* Propotional
8586
* PPS

cronjobs/archive_cleanup.php

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,9 @@
1919
2020
*/
2121

22+
// Change to working directory
23+
chdir(dirname(__FILE__));
24+
2225
// Include all settings and classes
2326
require_once('shared.inc.php');
2427

cronjobs/auto_payout.php

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,9 @@
1919
2020
*/
2121

22+
// Change to working directory
23+
chdir(dirname(__FILE__));
24+
2225
// Include all settings and classes
2326
require_once('shared.inc.php');
2427

cronjobs/blockupdate.php

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,9 @@
1919
2020
*/
2121

22+
// Change to working directory
23+
chdir(dirname(__FILE__));
24+
2225
// Include all settings and classes
2326
require_once('shared.inc.php');
2427

cronjobs/findblock.php

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,9 @@
1919
2020
*/
2121

22+
// Change to working directory
23+
chdir(dirname(__FILE__));
24+
2225
// Include all settings and classes
2326
require_once('shared.inc.php');
2427

cronjobs/manual_payout.php

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,9 @@
1919
2020
*/
2121

22+
// Change to working directory
23+
chdir(dirname(__FILE__));
24+
2225
// Include all settings and classes
2326
require_once('shared.inc.php');
2427

cronjobs/notifications.php

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,9 @@
1919
2020
*/
2121

22+
// Change to working directory
23+
chdir(dirname(__FILE__));
24+
2225
// Include all settings and classes
2326
require_once('shared.inc.php');
2427

cronjobs/pplns_payout.php

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,9 @@
1919
2020
*/
2121

22+
// Change to working directory
23+
chdir(dirname(__FILE__));
24+
2225
// Include all settings and classes
2326
require_once('shared.inc.php');
2427

@@ -45,7 +48,7 @@
4548
if ($config['pplns']['shares']['type'] == 'blockavg' && $block->getBlockCount() > 0) {
4649
$pplns_target = round($block->getAvgBlockShares($config['pplns']['blockavg']['blockcount']));
4750
} else {
48-
$pplns_target = $config['pplns']['shares']['default'] ;
51+
$pplns_target = $config['pplns']['shares']['default'];
4952
}
5053

5154
if (!$aBlock['accounted']) {
@@ -65,16 +68,21 @@
6568

6669
if ($iRoundShares >= $pplns_target) {
6770
$log->logDebug("Matching or exceeding PPLNS target of $pplns_target with $iRoundShares");
68-
$aAccountShares = $share->getSharesForAccounts($aBlock['share_id'] - $pplns_target, $aBlock['share_id']);
71+
$iMinimumShareId = $share->getMinimumShareId($pplns_target, $aBlock['share_id']);
72+
// We need to go one ID lower due to `id >` or we won't match if minimum share ID == $aBlock['share_id']
73+
$aAccountShares = $share->getSharesForAccounts($iMinimumShareId - 1, $aBlock['share_id']);
6974
if (empty($aAccountShares)) {
7075
$log->logFatal("No shares found for this block, aborted! Block Height : " . $aBlock['height']);
7176
$monitoring->setStatus($cron_name . "_active", "yesno", 0);
7277
$monitoring->setStatus($cron_name . "_message", "message", "No shares found for this block: " . $aBlock['height']);
7378
$monitoring->setStatus($cron_name . "_status", "okerror", 1);
7479
exit(1);
7580
}
76-
$log->logInfo('Adjusting round target to PPLNS target ' . $pplns_target);
77-
$iRoundShares = $pplns_target;
81+
foreach($aAccountShares as $key => $aData) {
82+
$iNewRoundShares += $aData['valid'];
83+
}
84+
$log->logInfo('Adjusting round target to PPLNS target ' . $iNewRoundShares);
85+
$iRoundShares = $iNewRoundShares;
7886
} else {
7987
$log->logDebug("Not able to match PPLNS target of $pplns_target with $iRoundShares");
8088
// We need to fill up with archived shares
@@ -153,6 +161,7 @@
153161
if (!$statistics->updateShareStatistics($aRoundData, $aBlock['id']))
154162
$log->logError('Failed to update share statistics for ' . $aData['username']);
155163
}
164+
156165
// Add new credit transaction
157166
if (!$transaction->addTransaction($aData['id'], $aData['payout'], 'Credit', $aBlock['id']))
158167
$log->logFatal('Failed to insert new Credit transaction to database for ' . $aData['username']);

cronjobs/pps_payout.php

Lines changed: 23 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,9 @@
1919
2020
*/
2121

22+
// Change to working directory
23+
chdir(dirname(__FILE__));
24+
2225
// Include all settings and classes
2326
require_once('shared.inc.php');
2427

@@ -42,18 +45,29 @@
4245
exit(1);
4346
}
4447

45-
// Value per share calculation
46-
if ($config['reward_type'] != 'block') {
47-
$pps_value = round($config['reward'] / (pow(2,32) * $dDifficulty) * pow(2, $config['difficulty']), 12);
48+
// We support some dynamic reward targets but fall back to our fixed value
49+
// Re-calculate after each run due to re-targets in this loop
50+
if ($config['pps']['reward']['type'] == 'blockavg' && $block->getBlockCount() > 0) {
51+
$pps_reward = round($block->getAvgBlockReward($config['pps']['blockavg']['blockcount']));
52+
$log->logInfo("PPS reward using block average, amount: " . $pps_reward . "\tdifficulty: " . $dDifficulty);
4853
} else {
49-
// Try to find the last block value and use that for future payouts, revert to fixed reward if none found
50-
if ($aLastBlock = $block->getLast()) {
51-
$pps_value = round($aLastBlock['amount'] / (pow(2,32) * $dDifficulty) * pow(2, $config['difficulty']), 12);
54+
if ($config['pps']['reward']['type'] == 'block') {
55+
if ($aLastBlock = $block->getLast()) {
56+
$pps_reward = $aLastBlock['amount'];
57+
$log->logInfo("PPS reward using last block, amount: " . $pps_reward . "\tdifficulty: " . $dDifficulty);
58+
} else {
59+
$pps_reward = $config['pps']['reward']['default'];
60+
$log->logInfo("PPS reward using default, amount: " . $pps_reward . "\tdifficulty: " . $dDifficulty);
61+
}
5262
} else {
53-
$pps_value = round($config['reward'] / (pow(2,32) * $dDifficulty) * pow(2, $config['difficulty']), 12);
63+
$pps_reward = $config['pps']['reward']['default'];
64+
$log->logInfo("PPS reward fixed default, amount: " . $pps_reward . "\tdifficulty: " . $dDifficulty);
5465
}
5566
}
5667

68+
// Per-share value to be paid out to users
69+
$pps_value = round($pps_reward / (pow(2,32) * $dDifficulty) * pow(2, $config['pps_target']), 12);
70+
5771
// Find our last share accounted and last inserted share for PPS calculations
5872
$iPreviousShareId = $setting->getValue('pps_last_share_id');
5973
$iLastShareId = $share->getLastInsertedShareId();
@@ -84,7 +98,7 @@
8498
number_format($pps_value, 12) . "\t=\t" .
8599
number_format($aData['payout'], 8) . "\t" .
86100
number_format($aData['donation'], 8) . "\t" .
87-
number_format($aData['fee']), 8);
101+
number_format($aData['fee'], 8));
88102

89103
// Add new credit transaction
90104
if (!$transaction->addTransaction($aData['id'], $aData['payout'], 'Credit_PPS'))
@@ -104,9 +118,7 @@
104118

105119
// Fetch all unaccounted blocks
106120
$aAllBlocks = $block->getAllUnaccounted('ASC');
107-
if (empty($aAllBlocks)) {
108-
$log->logDebug("No new unaccounted blocks found");
109-
}
121+
if (empty($aAllBlocks)) $log->logDebug("No new unaccounted blocks found");
110122

111123
// Go through blocks and archive/delete shares that have been accounted for
112124
foreach ($aAllBlocks as $iIndex => $aBlock) {

cronjobs/proportional_payout.php

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,9 @@
1919
2020
*/
2121

22+
// Change to working directory
23+
chdir(dirname(__FILE__));
24+
2225
// Include all settings and classes
2326
require_once('shared.inc.php');
2427

0 commit comments

Comments
 (0)