commit
9497823cd5
@ -534,6 +534,31 @@ class Statistics {
|
||||
$this->debug->append("Failed to fetch hourly hashrate: " . $this->mysqli->error);
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* get user estimated payouts based on share counts
|
||||
* @param aRoundShares array Round shares
|
||||
* @param aUserShares array User shares
|
||||
* @param dDonate double User donation setting
|
||||
* @param bNoFees bool User no-fees option setting
|
||||
* @return aEstimates array User estimations
|
||||
**/
|
||||
public function getUserEstimates($aRoundShares, $aUserShares, $dDonate, $bNoFees) {
|
||||
$this->debug->append("STA " . __METHOD__, 4);
|
||||
// Fetch some user information that we need
|
||||
if (@$aRoundShares['valid'] > 0 && @$aUserShares['valid'] > 0) {
|
||||
$aEstimates['block'] = round(( (int)$aUserShares['valid'] / (int)$aRoundShares['valid'] ) * (float)$this->config['reward'], 8);
|
||||
$bNoFees == 0 ? $aEstimates['fee'] = round(((float)$this->config['fees'] / 100) * (float)$aEstimates['block'], 8) : $aEstimates['fee'] = 0;
|
||||
$aEstimates['donation'] = round((( (float)$dDonate / 100) * ((float)$aEstimates['block'] - (float)$aEstimates['fee'])), 8);
|
||||
$aEstimates['payout'] = round((float)$aEstimates['block'] - (float)$aEstimates['donation'] - (float)$aEstimates['fee'], 8);
|
||||
} else {
|
||||
$aEstimates['block'] = 0;
|
||||
$aEstimates['fee'] = 0;
|
||||
$aEstimates['donation'] = 0;
|
||||
$aEstimates['payout'] = 0;
|
||||
}
|
||||
return $aEstimates;
|
||||
}
|
||||
}
|
||||
|
||||
$statistics = new Statistics($debug, $mysqli, $config, $share, $user, $block, $memcache);
|
||||
|
||||
@ -55,6 +55,9 @@ class User {
|
||||
public function getUserNoFee($id) {
|
||||
return $this->getSingle($id, 'no_fees', 'id');
|
||||
}
|
||||
public function getUserDonatePercent($id) {
|
||||
return $this->getDonatePercent($id);
|
||||
}
|
||||
public function getUserAdmin($id) {
|
||||
return $this->getSingle($id, 'is_admin', 'id');
|
||||
}
|
||||
|
||||
@ -37,6 +37,7 @@ $statistics->setGetCache(true);
|
||||
// Use caches for this one
|
||||
$aUserRoundShares = $statistics->getUserShares($user_id);
|
||||
$aRoundShares = $statistics->getRoundShares();
|
||||
$aEstimates = $statistics->getUserEstimates($aRoundShares, $aUserRoundShares, $user->getUserDonatePercent($user_id), $user->getUserNoFee($user_id));
|
||||
|
||||
// Apply pool modifiers
|
||||
$dPersonalHashrateAdjusted = $dPersonalHashrate * $dPersonalHashrateModifier;
|
||||
@ -46,7 +47,7 @@ $dNetworkHashrateAdjusted = $dNetworkHashrate / 1000 * $dNetworkHashrateModifier
|
||||
// Output JSON format
|
||||
$data = array(
|
||||
'raw' => array( 'personal' => array( 'hashrate' => $dPersonalHashrate ), 'pool' => array( 'hashrate' => $dPoolHashrate ), 'network' => array( 'hashrate' => $dNetworkHashrate / 1000 ) ),
|
||||
'personal' => array ( 'hashrate' => $dPersonalHashrateAdjusted, 'sharerate' => $dPersonalSharerate, 'shares' => $aUserRoundShares, 'balance' => $transaction->getBalance($user_id)),
|
||||
'personal' => array ( 'hashrate' => $dPersonalHashrateAdjusted, 'sharerate' => $dPersonalSharerate, 'shares' => $aUserRoundShares, 'balance' => $transaction->getBalance($user_id), 'estimates' => $aEstimates),
|
||||
'pool' => array( 'hashrate' => $dPoolHashrateAdjusted, 'shares' => $aRoundShares ),
|
||||
'network' => array( 'hashrate' => $dNetworkHashrateAdjusted, 'difficulty' => $dDifficulty, 'block' => $iBlock ),
|
||||
);
|
||||
|
||||
@ -128,17 +128,11 @@ if (@$_SESSION['USERDATA']['id']) {
|
||||
switch ($config['payout_system']) {
|
||||
case 'prop' || 'pplns':
|
||||
// Some estimations
|
||||
if (@$aRoundShares['valid'] > 0) {
|
||||
$aGlobal['userdata']['est_block'] = round(( (int)$aGlobal['userdata']['shares']['valid'] / (int)$aRoundShares['valid'] ) * (float)$config['reward'], 8);
|
||||
$aGlobal['userdata']['no_fees'] == 0 ? $aGlobal['userdata']['est_fee'] = round(((float)$config['fees'] / 100) * (float)$aGlobal['userdata']['est_block'], 8) : $aGlobal['userdata']['est_fee'] = 0;
|
||||
$aGlobal['userdata']['est_donation'] = round((( (float)$aGlobal['userdata']['donate_percent'] / 100) * ((float)$aGlobal['userdata']['est_block'] - (float)$aGlobal['userdata']['est_fee'])), 8);
|
||||
$aGlobal['userdata']['est_payout'] = round((float)$aGlobal['userdata']['est_block'] - (float)$aGlobal['userdata']['est_donation'] - (float)$aGlobal['userdata']['est_fee'], 8);
|
||||
} else {
|
||||
$aGlobal['userdata']['est_block'] = 0;
|
||||
$aGlobal['userdata']['est_fee'] = 0;
|
||||
$aGlobal['userdata']['est_donation'] = 0;
|
||||
$aGlobal['userdata']['est_payout'] = 0;
|
||||
}
|
||||
$aEstimates = $statistics->getUserEstimates($aRoundShares, $aGlobal['userdata']['shares'], $aGlobal['userdata']['donate_percent'], $aGlobal['userdata']['no_fees']);
|
||||
$aGlobal['userdata']['est_block'] = $aEstimates['block'];
|
||||
$aGlobal['userdata']['est_fee'] = $aEstimates['fee'];
|
||||
$aGlobal['userdata']['est_donation'] = $aEstimates['donation'];
|
||||
$aGlobal['userdata']['est_payout'] = $aEstimates['payout'];
|
||||
case 'pplns':
|
||||
$aGlobal['pplns']['target'] = $config['pplns']['shares']['default'];
|
||||
if ($aLastBlock = $block->getLast()) {
|
||||
|
||||
Loading…
Reference in New Issue
Block a user