mirror of
https://github.com/LBRYFoundation/pool.git
synced 2025-09-16 15:39:45 +00:00
profit: move sha256 GH/s factor in a function
todo: handle blake algos like sha
This commit is contained in:
parent
11d26c1f7d
commit
dac5d33e09
5 changed files with 22 additions and 17 deletions
|
@ -24,7 +24,8 @@ function BackendRentingUpdate()
|
||||||
$rent = dboscalar("select rent from hashrate where algo=:algo order by time desc limit 1", array(':algo'=>$submit->algo));
|
$rent = dboscalar("select rent from hashrate where algo=:algo order by time desc limit 1", array(':algo'=>$submit->algo));
|
||||||
$amount = $rent * $submit->difficulty / 20116.56761169;
|
$amount = $rent * $submit->difficulty / 20116.56761169;
|
||||||
|
|
||||||
if($submit->algo == 'sha256') $amount /= 1000;
|
$factor = yaamp_algo_mBTC_factor($submit->algo); // 1000 for sha256
|
||||||
|
$amount /= $factor;
|
||||||
|
|
||||||
$submit->amount = $amount - $amount*YAAMP_FEES_RENTING/100;
|
$submit->amount = $amount - $amount*YAAMP_FEES_RENTING/100;
|
||||||
$submit->status = 1;
|
$submit->status = 1;
|
||||||
|
|
|
@ -40,6 +40,18 @@ function yaamp_get_algos()
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Used for graphs and 24h profit
|
||||||
|
// GH/s for fast algos like sha256
|
||||||
|
function yaamp_algo_mBTC_factor($algo)
|
||||||
|
{
|
||||||
|
switch($algo) {
|
||||||
|
case 'sha256':
|
||||||
|
return 1000;
|
||||||
|
default:
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// mBTC coef per algo
|
// mBTC coef per algo
|
||||||
function yaamp_get_algo_norm($algo)
|
function yaamp_get_algo_norm($algo)
|
||||||
{
|
{
|
||||||
|
@ -240,8 +252,8 @@ function yaamp_profitability($coin)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if($coin->algo == 'sha256') $btcmhd *= 1000;
|
$algo_unit_factor = yaamp_algo_mBTC_factor($coin->algo);
|
||||||
return $btcmhd;
|
return $btcmhd * $algo_unit_factor;
|
||||||
}
|
}
|
||||||
|
|
||||||
function yaamp_convert_amount_user($coin, $amount, $user)
|
function yaamp_convert_amount_user($coin, $amount, $user)
|
||||||
|
|
|
@ -64,11 +64,8 @@ class ApiController extends CommonController
|
||||||
$hashrate1 = controller()->memcache->get_database_scalar("api_status_avghashrate-$algo",
|
$hashrate1 = controller()->memcache->get_database_scalar("api_status_avghashrate-$algo",
|
||||||
"select avg(hashrate) from hashrate where time>$t and algo=:algo", array(':algo'=>$algo));
|
"select avg(hashrate) from hashrate where time>$t and algo=:algo", array(':algo'=>$algo));
|
||||||
|
|
||||||
// $btcmhday1 = $hashrate1 != 0? bitcoinvaluetoa($total1 / $hashrate1 * 1000000): '0.00000000';
|
$algo_unit_factor = yaamp_algo_mBTC_factor($algo);
|
||||||
if($algo == 'sha256')
|
$btcmhday1 = $hashrate1 != 0? mbitcoinvaluetoa($total1 / $hashrate1 * 1000000 * 1000 * $algo_unit_factor): '';
|
||||||
$btcmhday1 = $hashrate1 != 0? mbitcoinvaluetoa($total1 / $hashrate1 * 1000000 * 1000000): '0';
|
|
||||||
else
|
|
||||||
$btcmhday1 = $hashrate1 != 0? mbitcoinvaluetoa($total1 / $hashrate1 * 1000000 * 1000): '0';
|
|
||||||
|
|
||||||
$fees = yaamp_fee($algo);
|
$fees = yaamp_fee($algo);
|
||||||
$port = getAlgoPort($algo);
|
$port = getAlgoPort($algo);
|
||||||
|
|
|
@ -96,10 +96,8 @@ foreach($algos as $item)
|
||||||
$total1 = dboscalar("select sum(amount*price) from blocks where category!='orphan' and time>$t1 and algo=:algo", array(':algo'=>$algo));
|
$total1 = dboscalar("select sum(amount*price) from blocks where category!='orphan' and time>$t1 and algo=:algo", array(':algo'=>$algo));
|
||||||
$hashrate1 = dboscalar("select avg(hashrate) from hashrate where time>$t1 and algo=:algo", array(':algo'=>$algo));
|
$hashrate1 = dboscalar("select avg(hashrate) from hashrate where time>$t1 and algo=:algo", array(':algo'=>$algo));
|
||||||
|
|
||||||
if($algo == 'sha256')
|
$algo_unit_factor = yaamp_algo_mBTC_factor($algo);
|
||||||
$btcmhday1 = $hashrate1 != 0? mbitcoinvaluetoa($total1 / $hashrate1 * 1000000 * 1000000): '';
|
$btcmhday1 = $hashrate1 != 0? mbitcoinvaluetoa($total1 / $hashrate1 * 1000000 * 1000 * $algo_unit_factor): '';
|
||||||
else
|
|
||||||
$btcmhday1 = $hashrate1 != 0? mbitcoinvaluetoa($total1 / $hashrate1 * 1000000 * 1000): '';
|
|
||||||
|
|
||||||
$fees = yaamp_fee($algo);
|
$fees = yaamp_fee($algo);
|
||||||
|
|
||||||
|
|
|
@ -101,11 +101,8 @@ foreach($algos as $item)
|
||||||
$hashrate1 = controller()->memcache->get_database_scalar("current_hashrate1-$algo",
|
$hashrate1 = controller()->memcache->get_database_scalar("current_hashrate1-$algo",
|
||||||
"select avg(hashrate) from hashrate where time>$t and algo=:algo", array(':algo'=>$algo));
|
"select avg(hashrate) from hashrate where time>$t and algo=:algo", array(':algo'=>$algo));
|
||||||
|
|
||||||
// $btcmhday1 = $hashrate1 != 0? mbitcoinvaluetoa($total1 / $hashrate1 * 1000000 * 1000): '-';
|
$algo_unit_factor = yaamp_algo_mBTC_factor($algo);
|
||||||
if($algo == 'sha256')
|
$btcmhday1 = $hashrate1 != 0? mbitcoinvaluetoa($total1 / $hashrate1 * 1000000 * 1000 * $algo_unit_factor): '';
|
||||||
$btcmhday1 = $hashrate1 != 0? mbitcoinvaluetoa($total1 / $hashrate1 * 1000000 * 1000000): '';
|
|
||||||
else
|
|
||||||
$btcmhday1 = $hashrate1 != 0? mbitcoinvaluetoa($total1 / $hashrate1 * 1000000 * 1000): '';
|
|
||||||
|
|
||||||
$fees = yaamp_fee($algo);
|
$fees = yaamp_fee($algo);
|
||||||
$port = getAlgoPort($algo);
|
$port = getAlgoPort($algo);
|
||||||
|
|
Loading…
Add table
Reference in a new issue