";
}
$algo = user()->getState('yaamp-algo');
$total_rate = Itoa2(yaamp_pool_rate());
$list = getdbolist('db_coins', "enable and algo=:algo order by index_avg desc", array(':algo'=>$algo));
$count = count($list);
$worker = getdbocount('db_workers', "algo=:algo", array(':algo'=>$algo));
$services = getdbolist('db_services', "algo=:algo order by price desc", array(':algo'=>$algo));
////////////
$table = array(
'scrypt'=>0,
'sha256'=>1,
'scryptn'=>2,
'x11'=>3,
'x13'=>4,
'x15'=>6,
'nist5'=>7,
'neoscrypt'=>8,
'lyra2'=>9,
);
$res = fetch_url("https://www.nicehash.com/api?method=orders.get&algo={$table[$algo]}");
if(!$res) return;
$a = json_decode($res);
$niceorders = $a->result->orders;
$allorders = array();
$nicehash = getdbosql('db_nicehash', "algo=:algo and orderid!=0", array(':algo'=>$algo));
if($nicehash)
{
$index = $nicehash->price*1000+1;
$allorders[$index] = array();
$allorders[$index]['speed'] = $nicehash->accepted;
$allorders[$index]['price'] = $nicehash->price;
$allorders[$index]['workers'] = $nicehash->workers;
$allorders[$index]['btc'] = $nicehash->btc;
$allorders[$index]['limit'] = $nicehash->speed;
$allorders[$index]['me'] = true;
}
foreach($niceorders as $order)
{
if(!$order->alive) continue;
if(!$order->workers) continue;
if(!$order->type == 0) continue;
$index = $order->price*1000;
if(!isset($allorders[$index]))
{
$allorders[$index] = array();
$allorders[$index]['price'] = $order->price;
$allorders[$index]['speed'] = 0;
$allorders[$index]['workers'] = 0;
$allorders[$index]['btc'] = 0;
$allorders[$index]['limit'] = 0;
}
$allorders[$index]['speed'] += $order->accepted_speed;
$allorders[$index]['workers'] += $order->workers;
$allorders[$index]['btc'] += $order->btc_avail;
$allorders[$index]['limit'] += $order->limit_speed;
}
$total_nicehash = 0;
foreach($allorders as $i=>$order)
$total_nicehash += $order['speed'];
function cmp($a, $b)
{
return $a['price'] < $b['price'];
}
usort($allorders, 'cmp');
///////
WriteBoxHeader("Mining $count coins at {$total_rate}h/s * with $worker miners ($algo)");
echo "
";
echo "";
echo "";
echo " | ";
echo "Name | ";
echo "max | ";
echo "mbtc | ";
echo "profit | ";
echo "TTF | ";
echo "Hash * | ";
echo "** | ";
echo "
";
echo "";
foreach($list as $coin)
{
$name = substr($coin->name, 0, 12);
$difficulty = Itoa2($coin->difficulty, 3);
$price = bitcoinvaluetoa($coin->price);
$height = number_format($coin->block_height, 0, '.', ' ');
$pool_ttf = $coin->pool_ttf? sectoa2($coin->pool_ttf): '';
$reward = round($coin->reward, 3);
$btcmhd = mbitcoinvaluetoa(yaamp_profitability($coin));
$pool_hash = yaamp_coin_rate($coin->id);
$pool_hash = $pool_hash? Itoa2($pool_hash).'h/s': '';
show_orders($allorders, $services, $btcmhd);
show_services($services, $btcmhd);
if(!$coin->auto_ready)
echo "";
else
echo "
";
echo " | ";
echo "$name | ";
echo "$reward $coin->symbol | ";
echo "$difficulty | ";
if(!empty($coin->errors))
echo "$height | ";
else
echo "$height | ";
echo "$pool_ttf | ";
echo "$pool_hash | ";
echo "$btcmhd | ";
echo "
";
}
show_orders($allorders, $services);
show_services($services);
echo "
";
/////////////////////////////////////////////////////////////////////////////////////////////
$target = yaamp_hashrate_constant($algo);
$interval = yaamp_hashrate_step();
$delay = time()-$interval;
$version = 'NiceHash/1.0.0';
$hashrate = dboscalar("select sum(difficulty) * $target / $interval / 1000 from shares where valid and time>$delay and
workerid in (select id from workers where algo=:algo and version='$version')", array(':algo'=>$algo));
$invalid = dboscalar("select sum(difficulty) * $target / $interval / 1000 from shares where not valid and time>$delay and
workerid in (select id from workers where algo=:algo and version='$version')", array(':algo'=>$algo));
$count = getdbocount('db_workers', "algo=:algo and version='$version'", array(':algo'=>$algo));
$percent = $total_nicehash&&$hashrate? round($hashrate * 100 / $total_nicehash / 1000000000, 2).'%': '';
$hashrate = $hashrate? Itoa2($hashrate).'h/s': '';
$version = substr($version, 0, 30);
$total_nicehash = round($total_nicehash, 3);
echo "Total Nicehash:
$total_nicehash Gh/s *** yaamp: ";
echo "
$hashrate ";
echo "$count workers ";
echo "$percent ";
echo "