Merge pull request #1003 from TheSerapher/issue-986
[FIX] Admin User Panel for PPS Payouts
This commit is contained in:
commit
cba4e5f1a4
@ -47,6 +47,7 @@ if ( $bitcoin->can_connect() === true ){
|
|||||||
|
|
||||||
// We support some dynamic reward targets but fall back to our fixed value
|
// We support some dynamic reward targets but fall back to our fixed value
|
||||||
// Re-calculate after each run due to re-targets in this loop
|
// Re-calculate after each run due to re-targets in this loop
|
||||||
|
// We don't use the classes implementation just in case people start mucking around with it
|
||||||
if ($config['pps']['reward']['type'] == 'blockavg' && $block->getBlockCount() > 0) {
|
if ($config['pps']['reward']['type'] == 'blockavg' && $block->getBlockCount() > 0) {
|
||||||
$pps_reward = round($block->getAvgBlockReward($config['pps']['blockavg']['blockcount']));
|
$pps_reward = round($block->getAvgBlockReward($config['pps']['blockavg']['blockcount']));
|
||||||
$log->logInfo("PPS reward using block average, amount: " . $pps_reward . "\tdifficulty: " . $dDifficulty);
|
$log->logInfo("PPS reward using block average, amount: " . $pps_reward . "\tdifficulty: " . $dDifficulty);
|
||||||
@ -65,7 +66,6 @@ if ($config['pps']['reward']['type'] == 'blockavg' && $block->getBlockCount() >
|
|||||||
// Per-share value to be paid out to users
|
// Per-share value to be paid out to users
|
||||||
$pps_value = round($pps_reward / (pow(2, $config['target_bits']) * $dDifficulty), 12);
|
$pps_value = round($pps_reward / (pow(2, $config['target_bits']) * $dDifficulty), 12);
|
||||||
|
|
||||||
|
|
||||||
// Find our last share accounted and last inserted share for PPS calculations
|
// Find our last share accounted and last inserted share for PPS calculations
|
||||||
$iPreviousShareId = $setting->getValue('pps_last_share_id');
|
$iPreviousShareId = $setting->getValue('pps_last_share_id');
|
||||||
$iLastShareId = $share->getLastInsertedShareId();
|
$iLastShareId = $share->getLastInsertedShareId();
|
||||||
|
|||||||
@ -822,7 +822,7 @@ class Statistics extends Base {
|
|||||||
/**
|
/**
|
||||||
* Get the Expected next Difficulty
|
* Get the Expected next Difficulty
|
||||||
* @return difficulty double Next difficulty
|
* @return difficulty double Next difficulty
|
||||||
*/
|
**/
|
||||||
public function getExpectedNextDifficulty(){
|
public function getExpectedNextDifficulty(){
|
||||||
if ($data = $this->memcache->get(__FUNCTION__)) return $data;
|
if ($data = $this->memcache->get(__FUNCTION__)) return $data;
|
||||||
|
|
||||||
@ -835,6 +835,34 @@ class Statistics extends Base {
|
|||||||
return round($dDifficulty * $this->config['cointarget'] / $this->getNetworkExpectedTimePerBlock(), 8);
|
return round($dDifficulty * $this->config['cointarget'] / $this->getNetworkExpectedTimePerBlock(), 8);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get current PPS value
|
||||||
|
* @return value double PPS Value
|
||||||
|
**/
|
||||||
|
|
||||||
|
public function getPPSValue() {
|
||||||
|
// Fetch RPC difficulty
|
||||||
|
if ($this->bitcoin->can_connect() === true) {
|
||||||
|
$dDifficulty = $this->bitcoin->getdifficulty();
|
||||||
|
} else {
|
||||||
|
$dDifficulty = 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($this->config['pps']['reward']['type'] == 'blockavg' && $this->block->getBlockCount() > 0) {
|
||||||
|
$pps_reward = round($this->block->getAvgBlockReward($this->config['pps']['blockavg']['blockcount']));
|
||||||
|
} else {
|
||||||
|
if ($this->config['pps']['reward']['type'] == 'block') {
|
||||||
|
if ($aLastBlock = $this->block->getLast()) {
|
||||||
|
$pps_reward = $aLastBlock['amount'];
|
||||||
|
} else {
|
||||||
|
$pps_reward = $this->config['pps']['reward']['default'];
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
$pps_reward = $this->config['pps']['reward']['default'];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return round($pps_reward / (pow(2, $this->config['target_bits']) * $dDifficulty), 12);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
$statistics = new Statistics();
|
$statistics = new Statistics();
|
||||||
|
|||||||
@ -40,7 +40,14 @@ if (@$_POST['query']) {
|
|||||||
$aBalance = $transaction->getBalance($aUser['id']);
|
$aBalance = $transaction->getBalance($aUser['id']);
|
||||||
$aUser['balance'] = $aBalance['confirmed'];
|
$aUser['balance'] = $aBalance['confirmed'];
|
||||||
$aUser['hashrate'] = $statistics->getUserHashrate($aUser['id']);
|
$aUser['hashrate'] = $statistics->getUserHashrate($aUser['id']);
|
||||||
$aUser['estimates'] = $statistics->getUserEstimates($aRoundShares, $aUser['shares'], $aUser['donate_percent'], $aUser['no_fees']);
|
|
||||||
|
if ($config['payout_system'] == 'pps') {
|
||||||
|
$aUser['sharerate'] = $statistics->getUserSharerate($aUser['id']);
|
||||||
|
$aUser['difficulty'] = $statistics->getUserShareDifficulty($aUser['id']);
|
||||||
|
$aUser['estimates'] = $statistics->getUserEstimates($aUser['sharerate'], $aUser['difficulty'], $user->getUserDonatePercent($aUser['id']), $user->getUserNoFee($aUser['id']), $statistics->getPPSValue());
|
||||||
|
} else {
|
||||||
|
$aUser['estimates'] = $statistics->getUserEstimates($aRoundShares, $aUser['shares'], $aUser['donate_percent'], $aUser['no_fees']);
|
||||||
|
}
|
||||||
$aUsers[$iKey] = $aUser;
|
$aUsers[$iKey] = $aUser;
|
||||||
}
|
}
|
||||||
// Assign our variables
|
// Assign our variables
|
||||||
|
|||||||
@ -58,22 +58,7 @@ if ($config['payout_system'] != 'pps') {
|
|||||||
$dUnpaidShares = 0;
|
$dUnpaidShares = 0;
|
||||||
} else {
|
} else {
|
||||||
$dUnpaidShares = $statistics->getUserUnpaidPPSShares($user_id, $setting->getValue('pps_last_share_id'));
|
$dUnpaidShares = $statistics->getUserUnpaidPPSShares($user_id, $setting->getValue('pps_last_share_id'));
|
||||||
if ($config['pps']['reward']['type'] == 'blockavg' && $block->getBlockCount() > 0) {
|
$aEstimates = $statistics->getUserEstimates($dPersonalSharerate, $dPersonalShareDifficulty, $user->getUserDonatePercent($user_id), $user->getUserNoFee($user_id), $statistics->getPPSValue());
|
||||||
$pps_reward = round($block->getAvgBlockReward($config['pps']['blockavg']['blockcount']));
|
|
||||||
} else {
|
|
||||||
if ($config['pps']['reward']['type'] == 'block') {
|
|
||||||
if ($aLastBlock = $block->getLast()) {
|
|
||||||
$pps_reward = $aLastBlock['amount'];
|
|
||||||
} else {
|
|
||||||
$pps_reward = $config['pps']['reward']['default'];
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
$pps_reward = $config['pps']['reward']['default'];
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
$ppsvalue = round($pps_reward / (pow(2,32) * $dDifficulty) * pow(2, $config['target_bits']), 12);
|
|
||||||
$aEstimates = $statistics->getUserEstimates($dPersonalSharerate, $dPersonalShareDifficulty, $user->getUserDonatePercent($user_id), $user->getUserNoFee($user_id), $ppsvalue);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
$iTotalRoundShares = $aRoundShares['valid'] + $aRoundShares['invalid'];
|
$iTotalRoundShares = $aRoundShares['valid'] + $aRoundShares['invalid'];
|
||||||
|
|||||||
@ -136,24 +136,8 @@ if (@$_SESSION['USERDATA']['id']) {
|
|||||||
$aGlobal['userdata']['estimates'] = $aEstimates;
|
$aGlobal['userdata']['estimates'] = $aEstimates;
|
||||||
break;
|
break;
|
||||||
case 'pps':
|
case 'pps':
|
||||||
// We support some dynamic reward targets but fall back to our fixed value
|
|
||||||
// Special calculations for PPS Values based on reward_type setting and/or available blocks
|
|
||||||
if ($config['pps']['reward']['type'] == 'blockavg' && $block->getBlockCount() > 0) {
|
|
||||||
$pps_reward = round($block->getAvgBlockReward($config['pps']['blockavg']['blockcount']));
|
|
||||||
} else {
|
|
||||||
if ($config['pps']['reward']['type'] == 'block') {
|
|
||||||
if ($aLastBlock = $block->getLast()) {
|
|
||||||
$pps_reward = $aLastBlock['amount'];
|
|
||||||
} else {
|
|
||||||
$pps_reward = $config['pps']['reward']['default'];
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
$pps_reward = $config['pps']['reward']['default'];
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
$aGlobal['userdata']['pps']['unpaidshares'] = $statistics->getUserUnpaidPPSShares($_SESSION['USERDATA']['id'], $setting->getValue('pps_last_share_id'));
|
$aGlobal['userdata']['pps']['unpaidshares'] = $statistics->getUserUnpaidPPSShares($_SESSION['USERDATA']['id'], $setting->getValue('pps_last_share_id'));
|
||||||
$aGlobal['ppsvalue'] = number_format(round($pps_reward / (pow(2, $config['target_bits']) * $dDifficulty), 12) ,12);
|
$aGlobal['ppsvalue'] = number_format($statistics->getPPSValue(), 12);
|
||||||
$aGlobal['poolppsvalue'] = $aGlobal['ppsvalue'] * pow(2, $config['difficulty'] - 16);
|
$aGlobal['poolppsvalue'] = $aGlobal['ppsvalue'] * pow(2, $config['difficulty'] - 16);
|
||||||
$aGlobal['userdata']['sharedifficulty'] = $statistics->getUserShareDifficulty($_SESSION['USERDATA']['id']);
|
$aGlobal['userdata']['sharedifficulty'] = $statistics->getUserShareDifficulty($_SESSION['USERDATA']['id']);
|
||||||
$aGlobal['userdata']['estimates'] = $statistics->getUserEstimates($aGlobal['userdata']['sharerate'], $aGlobal['userdata']['sharedifficulty'], $aGlobal['userdata']['donate_percent'], $aGlobal['userdata']['no_fees'], $aGlobal['ppsvalue']);
|
$aGlobal['userdata']['estimates'] = $statistics->getUserEstimates($aGlobal['userdata']['sharerate'], $aGlobal['userdata']['sharedifficulty'], $aGlobal['userdata']['donate_percent'], $aGlobal['userdata']['no_fees'], $aGlobal['ppsvalue']);
|
||||||
|
|||||||
@ -36,8 +36,12 @@
|
|||||||
<th align="left">E-Mail</th>
|
<th align="left">E-Mail</th>
|
||||||
<th align="right">Shares </th>
|
<th align="right">Shares </th>
|
||||||
<th align="right">Hashrate </th>
|
<th align="right">Hashrate </th>
|
||||||
|
{if $GLOBAL.config.payout_system != 'pps'}
|
||||||
<th align="right">Est. Donation </th>
|
<th align="right">Est. Donation </th>
|
||||||
<th align="right">Est. Payout </th>
|
<th align="right">Est. Payout </th>
|
||||||
|
{else}
|
||||||
|
<th align="right" colspan="2">Est. 24 Hours </th>
|
||||||
|
{/if}
|
||||||
<th align="right">Balance </th>
|
<th align="right">Balance </th>
|
||||||
<th align="center">Admin</th>
|
<th align="center">Admin</th>
|
||||||
<th align="center">Locked</th>
|
<th align="center">Locked</th>
|
||||||
@ -53,8 +57,12 @@
|
|||||||
<td align="left">{$USERS[user].email|escape}</td>
|
<td align="left">{$USERS[user].email|escape}</td>
|
||||||
<td align="right">{$USERS[user].shares.valid}</td>
|
<td align="right">{$USERS[user].shares.valid}</td>
|
||||||
<td align="right">{$USERS[user].hashrate}</td>
|
<td align="right">{$USERS[user].hashrate}</td>
|
||||||
|
{if $GLOBAL.config.payout_system != 'pps'}
|
||||||
<td align="right">{$USERS[user].estimates.donation|number_format:"8"}</td>
|
<td align="right">{$USERS[user].estimates.donation|number_format:"8"}</td>
|
||||||
<td align="right">{$USERS[user].estimates.payout|number_format:"8"}</td>
|
<td align="right">{$USERS[user].estimates.payout|number_format:"8"}</td>
|
||||||
|
{else}
|
||||||
|
<td align="right" colspan="2">{$USERS[user].estimates.hours24|number_format:"8"}</td>
|
||||||
|
{/if}
|
||||||
<td align="right">{$USERS[user].balance|number_format:"8"}</td>
|
<td align="right">{$USERS[user].balance|number_format:"8"}</td>
|
||||||
<td align="center">
|
<td align="center">
|
||||||
<input type="hidden" name="admin[{$USERS[user].id}]" value="0"/>
|
<input type="hidden" name="admin[{$USERS[user].id}]" value="0"/>
|
||||||
@ -86,8 +94,12 @@
|
|||||||
<th align="left">E-Mail</th>
|
<th align="left">E-Mail</th>
|
||||||
<th align="right">Shares </th>
|
<th align="right">Shares </th>
|
||||||
<th align="right">Hashrate </th>
|
<th align="right">Hashrate </th>
|
||||||
|
{if $GLOBAL.config.payout_system != 'pps'}
|
||||||
<th align="right">Est. Donation </th>
|
<th align="right">Est. Donation </th>
|
||||||
<th align="right">Est. Payout </th>
|
<th align="right">Est. Payout </th>
|
||||||
|
{else}
|
||||||
|
<th align="right" colspan="2">Est. 24 Hours </th>
|
||||||
|
{/if}
|
||||||
<th align="right">Balance </th>
|
<th align="right">Balance </th>
|
||||||
<th align="center">Admin</th>
|
<th align="center">Admin</th>
|
||||||
<th align="center">Locked</th>
|
<th align="center">Locked</th>
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user