コード例 #1
0
ファイル: ApiController.php プロジェクト: zarethernet/yaamp
 public function actionStatus()
 {
     if (!LimitRequest('api-status', 10)) {
         return;
     }
     echo "{";
     foreach (yaamp_get_algos() as $i => $algo) {
         if ($i) {
             echo ", ";
         }
         $coins = controller()->memcache->get_database_count_ex("api_status_coins-{$algo}", 'db_coins', "enable and visible and auto_ready and algo=:algo", array(':algo' => $algo));
         $hashrate = controller()->memcache->get_database_scalar("api_status_hashrate-{$algo}", "select hashrate from hashrate where algo=:algo order by time desc limit 1", array(':algo' => $algo));
         $price = controller()->memcache->get_database_scalar("api_status_price-{$algo}", "select price from hashrate where algo=:algo order by time desc limit 1", array(':algo' => $algo));
         $price = bitcoinvaluetoa(take_yaamp_fee($price / 1000, $algo));
         $rental = controller()->memcache->get_database_scalar("api_status_price-{$algo}", "select rent from hashrate where algo=:algo order by time desc limit 1", array(':algo' => $algo));
         $rental = bitcoinvaluetoa($rental);
         $t = time() - 24 * 60 * 60;
         $avgprice = controller()->memcache->get_database_scalar("api_status_avgprice-{$algo}", "select avg(price) from hashrate where algo=:algo and time>{$t}", array(':algo' => $algo));
         $avgprice = bitcoinvaluetoa(take_yaamp_fee($avgprice / 1000, $algo));
         $total1 = controller()->memcache->get_database_scalar("api_status_total-{$algo}", "select sum(amount*price) from blocks where category!='orphan' and time>{$t} and algo=:algo", array(':algo' => $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));
         //			$btcmhday1 = $hashrate1 != 0? bitcoinvaluetoa($total1 / $hashrate1 * 1000000): '0.00000000';
         if ($algo == 'sha256') {
             $btcmhday1 = $hashrate1 != 0 ? mbitcoinvaluetoa($total1 / $hashrate1 * 1000000 * 1000000) : '0';
         } else {
             $btcmhday1 = $hashrate1 != 0 ? mbitcoinvaluetoa($total1 / $hashrate1 * 1000000 * 1000) : '0';
         }
         $fees = yaamp_fee($algo);
         $port = getAlgoPort($algo);
         if ($port == '-') {
             $port = 0;
         }
         echo "\"{$algo}\": ";
         echo "{";
         echo "\"name\": \"{$algo}\", ";
         echo "\"port\": {$port}, ";
         echo "\"coins\": {$coins}, ";
         echo "\"fees\": {$fees}, ";
         echo "\"hashrate\": {$hashrate}, ";
         echo "\"estimate_current\": {$price}, ";
         echo "\"estimate_last24h\": {$avgprice}, ";
         echo "\"actual_last24h\": {$btcmhday1}, ";
         echo "\"rental_current\": {$rental}";
         echo "}";
     }
     echo "}";
 }
コード例 #2
0
    public function actionOrderDialog()
    {
        $renter = getrenterparam(getparam('address'));
        if (!$renter) {
            return;
        }
        $a = 'x11';
        $server = '';
        $username = '';
        $password = '******';
        $percent = '';
        $price = '';
        $speed = '';
        $id = 0;
        $job = getdbo('db_jobs', getiparam('id'));
        if ($job) {
            $id = $job->id;
            $a = $job->algo;
            $server = "{$job->host}:{$job->port}";
            $username = $job->username;
            $password = $job->password;
            $percent = $job->percent;
            $price = mbitcoinvaluetoa($job->price);
            $speed = $job->speed / 1000000;
        }
        echo <<<end
<form id='order-edit-form' action='/renting/ordersave' method='post'>
<input type="hidden" value='{$id}' name="order_id">
<input type="hidden" value='{$renter->id}' name="order_renterid">
<input type="hidden" value='{$renter->address}' name="order_address">
\t\t
<p>Enter your job information below and click Submit when you are ready.</p>
\t\t
<table cellspacing=10 width=100%>
<tr><td>Algo:</td><td><select class="main-text-input" name="order_algo">
end;
        foreach (yaamp_get_algos() as $algo) {
            if (!controller()->admin && $algo == 'sha256') {
                continue;
            }
            if (!controller()->admin && $algo == 'scryptn') {
                continue;
            }
            $selected = $algo == $a ? 'selected' : '';
            echo "<option {$selected} value='{$algo}'>{$algo}</option>";
        }
        echo <<<end
</select></td></tr>
<tr><td>Server:</td><td><input type="text" value='{$server}' name="order_host" class="main-text-input" placeholder="stratum.server.com:3333"></td></tr>
<tr><td>Username:</td><td><input type="text" value='{$username}' name="order_username" class="main-text-input" placeholder="wallet_address"></td></tr>
<tr><td>Password:</td><td><input type="text" value='{$password}' name="order_password" class="main-text-input"></td></tr>
<tr><td>Max Price<br><span style='font-size: .8em;'>(mBTC/mh/day)</span>:</td><td><input type="text" value='{$price}' name="order_price" class="main-text-input" placeholder=""></td></tr>
<tr><td width=110>Max Hashrate<br><span style='font-size: .8em;'>(Mh/s)</span>:</td><td><input type="text" value='{$speed}' name="order_speed" class="main-text-input" placeholder=""></td></tr>
end;
        if (controller()->admin) {
            echo "<tr><td>Percent:</td><td><input type=text value='{$percent}' name=order_percent class=main-text-input></td></tr>";
        }
        echo "</table></form>";
    }
コード例 #3
0
ファイル: index.php プロジェクト: zarethernet/yaamp
    $btcmhday1 = bitcoinvaluetoa($row1['b'] / $row1['a'] * 1000000 / 2);
    $btcmhday2 = bitcoinvaluetoa($row2['b'] / $row2['a'] * 1000000 / 7);
    $btcmhday3 = bitcoinvaluetoa($row3['b'] / $row3['a'] * 1000000 / 30);
} else {
    $btcmhday1 = 0;
    $btcmhday2 = 0;
    $btcmhday3 = 0;
}
$hashrate1 = Itoa2($row1['a']);
$hashrate2 = Itoa2($row2['a']);
$hashrate3 = Itoa2($row3['a']);
$total1 = bitcoinvaluetoa($row1['b']);
$total2 = bitcoinvaluetoa($row2['b']);
$total3 = bitcoinvaluetoa($row3['b']);
$height = '240px';
$algos = yaamp_get_algos();
$string = '';
foreach ($algos as $a) {
    if ($a == $algo) {
        $string .= "<option value='{$a}' selected>{$a}</option>";
    } else {
        $string .= "<option value='{$a}'>{$a}</option>";
    }
}
echo <<<end

<div id='resume_update_button' style='color: #444; background-color: #ffd; border: 1px solid #eea;
\tpadding: 10px; margin-left: 20px; margin-right: 20px; margin-top: 15px; cursor: pointer; display: none;'
\tonclick='auto_page_resume();' align=center>
\t<b>Auto refresh is paused - Click to resume</b></div>
コード例 #4
0
ファイル: stats.php プロジェクト: Bitcoinsulting/yiimp
function BackendStatsUpdate()
{
    //	debuglog(__FUNCTION__);
    //	$t1xx = microtime(true);
    $t = time() - 2 * 60;
    $errors = '';
    $list = getdbolist('db_stratums', "time<{$t}");
    foreach ($list as $stratum) {
        debuglog("stratum {$stratum->algo} terminated");
        $errors .= "{$stratum->algo}, ";
    }
    if (!empty($errors)) {
        send_email_alert('stratums', "stratums restarted {$errors}", "stratums were restarted: {$errors}");
    }
    dborun("delete from stratums where time<{$t}");
    dborun("delete from workers where pid not in (select pid from stratums)");
    //////////////////////////////////////////////////////////////////////////////////////////////////////
    // long term stats
    $t = floor(time() / 60 / 60) * 60 * 60;
    foreach (yaamp_get_algos() as $algo) {
        $pool_rate = yaamp_pool_rate($algo);
        $stats = getdbosql('db_hashstats', "time={$t} and algo=:algo", array(':algo' => $algo));
        if (!$stats) {
            $stats = new db_hashstats();
            $stats->time = $t;
            $stats->hashrate = $pool_rate;
            $stats->algo = $algo;
        } else {
            $percent = 1;
            $stats->hashrate = round(($stats->hashrate * (100 - $percent) + $pool_rate * $percent) / 100);
        }
        $stats->earnings = dboscalar("select sum(amount*price) from blocks where time>{$t} and category!='orphan' and algo=:algo", array(':algo' => $algo));
        $stats->save();
    }
    ////////////////////////////////////////////////////////////////////////////////////////////////////
    // short term stats
    $step = 15;
    $t = floor(time() / $step / 60) * $step * 60;
    foreach (yaamp_get_algos() as $algo) {
        $stats = getdbosql('db_hashrate', "time={$t} and algo=:algo", array(':algo' => $algo));
        if (!$stats) {
            $stats = new db_hashrate();
            $stats->time = $t;
            $stats->hashrate = dboscalar("select hashrate from hashrate where algo=:algo order by time desc limit 1", array(':algo' => $algo));
            $stats->hashrate_bad = 0;
            //dboscalar("select hashrate_bad from hashrate where algo=:algo order by time desc limit 1", array(':algo'=>$algo));
            $stats->price = dboscalar("select price from hashrate where algo=:algo order by time desc limit 1", array(':algo' => $algo));
            $stats->rent = dboscalar("select rent from hashrate where algo=:algo order by time desc limit 1", array(':algo' => $algo));
            $stats->algo = $algo;
        }
        $pool_rate = yaamp_pool_rate($algo);
        $stats->hashrate = $pool_rate;
        //round(($stats->hashrate*(100-$percent) + $pool_rate*$percent) / 100);
        $pool_rate_bad = yaamp_pool_rate_bad($algo);
        $stats->hashrate_bad = $pool_rate_bad;
        //round(($stats->hashrate_bad*(100-$percent) + $pool_rate_bad*$percent) / 100);
        if ($stats->hashrate < 1000) {
            $stats->hashrate = 0;
        }
        $t1 = time() - 5 * 60;
        $total_rentable = dboscalar("select sum(difficulty) from shares where valid and extranonce1 and algo=:algo and time>{$t1}", array(':algo' => $algo));
        $total_diff = dboscalar("select sum(difficulty) from shares where valid and algo=:algo and time>{$t1}", array(':algo' => $algo));
        $total_rented = 0;
        if (!$total_diff) {
            $t1 = time() - 15 * 60;
            $total_diff = dboscalar("select sum(difficulty) from shares where valid and algo=:algo and time>{$t1}", array(':algo' => $algo));
        }
        if ($total_diff > 0) {
            $price = 0;
            $rent = 0;
            $list = dbolist("select coinid, sum(difficulty) as d from shares where valid and algo=:algo and time>{$t1} group by coinid", array(':algo' => $algo));
            foreach ($list as $item) {
                if ($item['coinid'] == 0) {
                    if (!$total_rentable) {
                        continue;
                    }
                    $total_rented = $item['d'];
                    $price += $stats->rent * $item['d'] / $total_diff;
                    $rent += $stats->rent * $item['d'] / $total_rentable;
                } else {
                    $coin = getdbo('db_coins', $item['coinid']);
                    if (!$coin) {
                        continue;
                    }
                    $btcghd = yaamp_profitability($coin);
                    $price += $btcghd * $item['d'] / $total_diff;
                    $rent += $btcghd * $item['d'] / $total_diff;
                }
            }
            $percent = 33;
            $rent = max($price, ($stats->rent * (100 - $percent) + $rent * $percent) / 100);
            $target = yaamp_hashrate_constant($algo);
            $interval = yaamp_hashrate_step();
            $aa = $total_rentable * $target / $interval / 1000;
            $bb = dboscalar("select sum(speed) from jobs where active and ready and price>{$rent} and algo=:algo", array(':algo' => $algo));
            if ($total_rented * 1.3 < $total_rentable || $bb > $aa) {
                $rent += $price * YAAMP_FEES_RENTING / 100;
            } else {
                $rent -= $price * YAAMP_FEES_RENTING / 100;
            }
            $stats->price = $price;
            $stats->rent = $rent;
        } else {
            $coin = getdbosql('db_coins', "enable and auto_ready and algo=:algo order by index_avg desc", array(':algo' => $algo));
            if ($coin) {
                $btcghd = yaamp_profitability($coin);
                $stats->price = $btcghd;
                $stats->rent = $stats->price + $stats->price * YAAMP_FEES_RENTING / 100;
            }
        }
        if (YAAMP_LIMIT_ESTIMATE) {
            $t1 = time() - 24 * 60 * 60;
            $avg = dboscalar("select avg(price) from hashrate where time>{$t1} and algo=:algo", array(':algo' => $algo));
            if ($avg) {
                $stats->price = min($stats->price, $avg * 1.5);
            }
        }
        $stats->difficulty = dboscalar("select sum(difficulty) from coins where enable and auto_ready and algo=:algo", array(':algo' => $algo));
        $stats->save();
    }
    //////////////////////////////////////////////////////////////
    $step = 15;
    $t = floor(time() / $step / 60) * $step * 60;
    $btc = getdbosql('db_coins', "symbol='BTC'");
    $topay = dboscalar("select sum(balance) from accounts where coinid={$btc->id}");
    //here: take other currencies too
    $margin = $btc->balance - $topay;
    $balances = dboscalar("select sum(balance) from balances");
    $onsell = dboscalar("select sum(amount*bid) from orders");
    $immature = dboscalar("select sum(amount*price) from earnings where status=0");
    $confirmed = dboscalar("select sum(amount*price) from earnings where status=1");
    $wallets = dboscalar("select sum(balance*price) from coins where enable and symbol!='BTC'");
    $renters = dboscalar("select sum(balance) from renters");
    $mints = dboscalar("select sum(mint*price) from coins where enable");
    $off = $mints - $immature;
    //	debuglog("mint $mints $immature $off");
    $total_profit = $btc->balance + $balances + $onsell + $wallets - $topay - $renters;
    $stats = getdbosql('db_stats', "time={$t}");
    if (!$stats) {
        $stats = new db_stats();
        $stats->time = $t;
    }
    $stats->profit = $total_profit;
    $stats->wallet = $btc->balance;
    $stats->wallets = $wallets;
    $stats->margin = $margin;
    $stats->balances = $balances;
    $stats->onsell = $onsell;
    $stats->immature = $immature;
    $stats->waiting = $confirmed;
    $stats->renters = $renters;
    $stats->save();
    /////////////////////////////////////////////////////////////////////////////
    foreach (yaamp_get_algos() as $algo) {
        $factor = yaamp_get_algo_norm($algo);
        $dbalgo = getdbosql('db_algos', "name='{$algo}'");
        if (!$dbalgo) {
            $dbalgo = new db_algos();
            $dbalgo->name = $algo;
        }
        $dbalgo->profit = dboscalar("select price from hashrate where algo=:algo order by time desc limit 1", array(':algo' => $algo));
        $dbalgo->rent = dboscalar("select rent from hashrate where algo=:algo order by time desc limit 1", array(':algo' => $algo));
        $dbalgo->factor = $factor;
        $dbalgo->save();
    }
    //	$d1 = microtime(true) - $t1xx;
    //	controller()->memcache->add_monitoring_function(__METHOD__, $d1);
}
コード例 #5
0
ファイル: renting.php プロジェクト: Bitcoinsulting/yiimp
function BackendRentingPayout()
{
    //	debuglog(__FUNCTION__);
    $total_cleared = 0;
    foreach (yaamp_get_algos() as $algo) {
        $delay = time() - 5 * 60;
        dborun("delete from jobsubmits where status=2 and algo=:algo and time<{$delay}", array(':algo' => $algo));
        $amount = dboscalar("select sum(amount) from jobsubmits where status=1 and algo=:algo", array(':algo' => $algo));
        if ($amount < 2.0E-5) {
            continue;
        }
        dborun("update jobsubmits set status=2 where status=1 and algo=:algo", array(':algo' => $algo));
        $total_cleared += $amount;
        $block = new db_blocks();
        $block->coin_id = 0;
        $block->time = time();
        $block->amount = $amount;
        $block->price = 1;
        $block->algo = $algo;
        $block->category = 'generate';
        $block->save();
        $total_hash_power = dboscalar("SELECT sum(difficulty) FROM shares where valid and algo=:algo", array(':algo' => $algo));
        if (!$total_hash_power) {
            continue;
        }
        $list = dbolist("SELECT userid, sum(difficulty) as total FROM shares where valid and algo=:algo GROUP BY userid", array(':algo' => $algo));
        foreach ($list as $item) {
            $hash_power = $item['total'];
            if (!$hash_power) {
                continue;
            }
            $user = getdbo('db_accounts', $item['userid']);
            if (!$user) {
                continue;
            }
            $earning = new db_earnings();
            $earning->userid = $user->id;
            $earning->coinid = 0;
            $earning->blockid = $block->id;
            $earning->create_time = time();
            $earning->price = 1;
            $earning->status = 2;
            // cleared
            $earning->amount = $amount * $hash_power / $total_hash_power;
            if (!$user->no_fees) {
                $earning->amount = take_yaamp_fee($earning->amount, $algo);
            }
            $earning->save();
            $refcoin = getdbo('db_coins', $user->coinid);
            $value = $earning->amount / ($refcoin && $refcoin->price2 ? $refcoin->price2 : 1);
            //	$value = yaamp_convert_amount_user($coin, $earning->amount, $user);
            $user->last_login = time();
            $user->balance += $value;
            $user->save();
        }
        $delay = time() - 5 * 60;
        dborun("delete from shares where algo=:algo and time<{$delay}", array(':algo' => $algo));
    }
    if ($total_cleared > 0) {
        debuglog("total cleared from rental {$total_cleared} BTC");
    }
}
コード例 #6
0
ファイル: status_results.php プロジェクト: zarethernet/yaamp
showTableSorter('maintable3');
echo "<thead>";
echo "<tr>";
echo "<th>Algo</th>";
echo "<th align=right>Jobs</th>";
echo "<th align=right>Total</th>";
//echo "<th>For Rent**</th>";
echo "<th align=right>Rented</th>";
echo "<th></th>";
echo "<th align=right>Available</th>";
//echo "<th>Paying</th>";
echo "<th align=right>Current Price</th>";
echo "</tr>";
echo "</thead>";
$algos = array();
foreach (yaamp_get_algos() as $algo) {
    $algo_norm = yaamp_get_algo_norm($algo);
    $price = controller()->memcache->get_database_scalar("current_price-{$algo}", "select price from hashrate where algo=:algo order by time desc limit 1", array(':algo' => $algo));
    $norm = $price * $algo_norm;
    $norm = take_yaamp_fee($norm, $algo);
    $algos[] = array($norm, $algo);
}
function cmp($a, $b)
{
    return $a[0] < $b[0];
}
usort($algos, 'cmp');
foreach ($algos as $item) {
    $norm = $item[0];
    $algo = $item[1];
    $count1 = getdbocount('db_jobs', "algo=:algo and ready and active", array(':algo' => $algo));
コード例 #7
0
ファイル: coins.php プロジェクト: Bitcoinsulting/yiimp
function BackendCoinsUpdate()
{
    //	debuglog(__FUNCTION__);
    $t1 = microtime(true);
    $pool_rate = array();
    foreach (yaamp_get_algos() as $algo) {
        $pool_rate[$algo] = yaamp_pool_rate($algo);
    }
    $coins = getdbolist('db_coins', "installed");
    foreach ($coins as $coin) {
        //		debuglog("doing $coin->name");
        $coin = getdbo('db_coins', $coin->id);
        if (!$coin) {
            continue;
        }
        $remote = new Bitcoin($coin->rpcuser, $coin->rpcpasswd, $coin->rpchost, $coin->rpcport);
        $info = $remote->getinfo();
        if (!$info) {
            $coin->enable = false;
            //	$coin->auto_ready = false;
            $coin->connections = 0;
            $coin->save();
            continue;
        }
        //		debuglog($info);
        $coin->enable = true;
        if (isset($info['difficulty'])) {
            $difficulty = $info['difficulty'];
        } else {
            $difficulty = $remote->getdifficulty();
        }
        if (is_array($difficulty)) {
            $coin->difficulty = $difficulty['proof-of-work'];
            if (isset($difficulty['proof-of-stake'])) {
                $coin->difficulty_pos = $difficulty['proof-of-stake'];
            }
        } else {
            $coin->difficulty = $difficulty;
        }
        if ($coin->algo == 'quark') {
            $coin->difficulty /= 0x100;
        }
        if ($coin->difficulty == 0) {
            $coin->difficulty = 1;
        }
        $coin->errors = isset($info['errors']) ? $info['errors'] : '';
        $coin->txfee = isset($info['paytxfee']) ? $info['paytxfee'] : '';
        $coin->connections = isset($info['connections']) ? $info['connections'] : '';
        $coin->balance = isset($info['balance']) ? $info['balance'] : 0;
        $coin->mint = dboscalar("select sum(amount) from blocks where coin_id={$coin->id} and category='immature'");
        if (empty($coin->master_wallet)) {
            $coin->master_wallet = $remote->getaccountaddress('');
            //	debuglog($coin->master_wallet);
        }
        if (empty($coin->rpcencoding)) {
            $difficulty = $remote->getdifficulty();
            if (is_array($difficulty)) {
                $coin->rpcencoding = 'POS';
            } else {
                $coin->rpcencoding = 'POW';
            }
        }
        if ($coin->hassubmitblock == NULL) {
            $remote->submitblock('');
            if (strcasecmp($remote->error, 'method not found') == 0) {
                $coin->hassubmitblock = false;
            } else {
                $coin->hassubmitblock = true;
            }
        }
        if ($coin->auxpow == NULL) {
            $ret = $remote->getauxblock();
            if (strcasecmp($remote->error, 'method not found') == 0) {
                $coin->auxpow = false;
            } else {
                $coin->auxpow = true;
            }
        }
        //		if($coin->symbol != 'BTC')
        //		{
        //			if($coin->symbol == 'PPC')
        //				$template = $remote->getblocktemplate('');
        //			else
        $template = $remote->getblocktemplate('{}');
        if ($template && isset($template['coinbasevalue'])) {
            $coin->reward = $template['coinbasevalue'] / 100000000 * $coin->reward_mul;
            if ($coin->symbol == 'TAC' && isset($template['_V2'])) {
                $coin->charity_amount = $template['_V2'] / 100000000;
            }
            if (isset($template['payee_amount']) && $coin->symbol != 'LIMX') {
                $coin->charity_amount = $template['payee_amount'] / 100000000;
                $coin->reward -= $coin->charity_amount;
                //	debuglog("$coin->symbol $coin->charity_amount $coin->reward");
            } else {
                if (!empty($coin->charity_address)) {
                    if ($coin->charity_amount) {
                    } else {
                        $coin->reward -= $coin->reward * $coin->charity_percent / 100;
                    }
                }
            }
            if (isset($template['bits'])) {
                $target = decode_compact($template['bits']);
                $coin->difficulty = target_to_diff($target);
            }
        } else {
            if (strcasecmp($remote->error, 'method not found') == 0) {
                $template = $remote->getmemorypool();
                if ($template && isset($template['coinbasevalue'])) {
                    $coin->usememorypool = true;
                    $coin->reward = $template['coinbasevalue'] / 100000000 * $coin->reward_mul;
                    if (isset($template['bits'])) {
                        $target = decode_compact($template['bits']);
                        $coin->difficulty = target_to_diff($target);
                    }
                } else {
                    $coin->auto_ready = false;
                    $coin->errors = $remote->error;
                }
            } else {
                $coin->auto_ready = false;
                $coin->errors = $remote->error;
            }
        }
        if (strcasecmp($coin->errors, 'No more PoW blocks') == 0) {
            $coin->dontsell = true;
            $coin->auto_ready = false;
        }
        //		}
        if ($coin->block_height != $info['blocks']) {
            $count = $info['blocks'] - $coin->block_height;
            $ttf = (time() - $coin->last_network_found) / $count;
            if (empty($coin->actual_ttf)) {
                $coin->actual_ttf = $ttf;
            }
            $coin->actual_ttf = percent_feedback($coin->actual_ttf, $ttf, 5);
            $coin->last_network_found = time();
        }
        $coin->version = $info['version'];
        $coin->block_height = $info['blocks'];
        $coin->save();
        //	debuglog(" end $coin->name");
    }
    $coins = getdbolist('db_coins', "enable order by auxpow desc");
    foreach ($coins as $coin) {
        $coin = getdbo('db_coins', $coin->id);
        if (!$coin) {
            continue;
        }
        if ($coin->difficulty) {
            $coin->index_avg = $coin->reward * $coin->price * 10000 / $coin->difficulty;
            if (!$coin->auxpow && $coin->rpcencoding == 'POW') {
                $indexaux = dboscalar("select sum(index_avg) from coins where enable and visible and auto_ready and auxpow and algo='{$coin->algo}'");
                $coin->index_avg += $indexaux;
            }
        }
        if ($coin->network_hash) {
            $coin->network_ttf = $coin->difficulty * 0x100000000 / $coin->network_hash;
        }
        if (isset($pool_rate[$coin->algo])) {
            $coin->pool_ttf = $coin->difficulty * 0x100000000 / $pool_rate[$coin->algo];
        }
        if (strstr($coin->image, 'http')) {
            $data = file_get_contents($coin->image);
            $coin->image = "/images/coin-{$coin->id}.png";
            @unlink(YAAMP_HTDOCS . $coin->image);
            file_put_contents(YAAMP_HTDOCS . $coin->image, $data);
        }
        $coin->save();
    }
    $d1 = microtime(true) - $t1;
    controller()->memcache->add_monitoring_function(__METHOD__, $d1);
}