Esempio n. 1
0
echo "<th>Renter</th>";
echo "<th>Job</th>";
echo "<th>Address</th>";
echo "<th>Algo</th>";
echo "<th>Host</th>";
echo "<th>Max Price</th>";
echo "<th>Max Hash</th>";
echo "<th>Current Hash</th>";
echo "<th>Difficulty</th>";
echo "<th>Ready</th>";
echo "<th>Active</th>";
echo "</tr>";
echo "</thead><tbody>";
$list = getdbolist('db_jobs', "ready");
foreach ($list as $job) {
    $hashrate = yaamp_job_rate($job->id);
    $hashrate = $hashrate ? Itoa2($hashrate) . 'h/s' : '';
    $speed = Itoa2($job->speed) . 'h/s';
    $renter = getdbo('db_renters', $job->renterid);
    if (!$renter) {
        continue;
    }
    if ($deposit == $renter->address) {
        echo "<tr class='ssrow' style='background-color: #dfd'>";
    } else {
        echo "<tr class='ssrow'>";
    }
    echo "<td>{$job->renterid}</td>";
    echo "<td>{$job->id}</td>";
    echo "<td><a href='/renting?address={$renter->address}'>{$renter->address}</a></td>";
    echo "<td>{$job->algo}</td>";
Esempio n. 2
0
function BackendStatsUpdate2()
{
    //	debuglog('----------------------------------');
    //	debuglog(__FUNCTION__);
    ////////////////////////////////////////////////////////////////////////////////////////////////////
    $step = 15;
    $t = floor(time() / $step / 60) * $step * 60;
    $list = dbolist("select userid, algo from shares where time>{$t} group by userid, algo");
    foreach ($list as $item) {
        $stats = getdbosql('db_hashuser', "time={$t} and algo=:algo and userid=:userid", array(':algo' => $item['algo'], ':userid' => $item['userid']));
        if (!$stats) {
            $stats = new db_hashuser();
            $stats->userid = $item['userid'];
            $stats->time = $t;
            $stats->hashrate = dboscalar("select hashrate from hashuser where algo=:algo and userid=:userid order by time desc limit 1", array(':algo' => $item['algo'], ':userid' => $item['userid']));
            $stats->hashrate_bad = 0;
            $stats->algo = $item['algo'];
        }
        $percent = 20;
        $user_rate = yaamp_user_rate($item['userid'], $item['algo']);
        $stats->hashrate = round(($stats->hashrate * (100 - $percent) + $user_rate * $percent) / 100);
        if ($stats->hashrate < 1000) {
            $stats->hashrate = 0;
        }
        $user_rate_bad = yaamp_user_rate_bad($item['userid'], $item['algo']);
        $stats->hashrate_bad = round(($stats->hashrate_bad * (100 - $percent) + $user_rate_bad * $percent) / 100);
        if ($stats->hashrate_bad < 1000) {
            $stats->hashrate_bad = 0;
        }
        $stats->save();
    }
    ////////////////////////////////////////////////////////////////////////////////////////////////////
    $step = 15;
    $t = floor(time() / $step / 60) * $step * 60;
    $list = dbolist("select distinct jobid from jobsubmits where time>{$t}");
    foreach ($list as $item) {
        $jobid = $item['jobid'];
        $stats = getdbosql('db_hashrenter', "time={$t} and jobid={$jobid}");
        if (!$stats) {
            $stats = new db_hashrenter();
            //	$stats->renterid = ;
            $stats->jobid = $item['jobid'];
            $stats->time = $t;
            $stats->hashrate = dboscalar("select hashrate from hashrenter where jobid=:jobid order by time desc limit 1", array(':jobid' => $jobid));
            $stats->hashrate_bad = 0;
            //dboscalar("select hashrate_bad from hashrenter where jobid=$jobid order by time desc limit 1");
        }
        $percent = 20;
        $job_rate = yaamp_job_rate($jobid);
        $stats->hashrate = round(($stats->hashrate * (100 - $percent) + $job_rate * $percent) / 100);
        if ($stats->hashrate < 1000) {
            $stats->hashrate = 0;
        }
        $job_rate_bad = yaamp_job_rate_bad($jobid);
        $stats->hashrate_bad = round(($stats->hashrate_bad * (100 - $percent) + $job_rate_bad * $percent) / 100);
        if ($stats->hashrate_bad < 1000) {
            $stats->hashrate_bad = 0;
        }
        $stats->save();
    }
    ////////////////////////////////////////////////////////////////////////////////////////////////////
    $t = floor(time() / $step / 60) * $step * 60;
    $d = time() - 24 * 60 * 60;
    $list = getdbolist('db_accounts', "balance>0 or last_login>{$d}");
    foreach ($list as $user) {
        $stats = getdbosql('db_balanceuser', "time={$t} and userid={$user->id}");
        if (!$stats) {
            $stats = new db_balanceuser();
            $stats->userid = $user->id;
            $stats->time = $t;
        }
        // 		$refcoin = getdbo('db_coins', $user->coinid);
        // 		if(!$refcoin) $refcoin = getdbosql('db_coins', "symbol='BTC'");
        // 		if(!$refcoin->price || !$refcoin->price2) continue;
        // 		$pending1 = dboscalar("select sum(amount*price) from earnings where coinid=$refcoin->id and status!=2 and userid=$user->id");
        // 		$pending2 = dboscalar("select sum(amount*price) from earnings where coinid!=$refcoin->id and status!=2 and userid=$user->id");
        $stats->pending = yaamp_convert_earnings_user($user, "status!=2");
        $stats->pending = bitcoinvaluetoa($stats->pending);
        $stats->balance = $user->balance;
        $stats->save();
        $id = dboscalar("select id from earnings where userid={$user->id} order by id desc limit 100, 1");
        if ($id) {
            dborun("delete from earnings where status=2 and userid={$user->id} and id<{$id}");
        }
    }
}
Esempio n. 3
0
<?php

$percent = 16;
$step = 15 * 60;
$t = time() - 24 * 60 * 60;
$jobid = getparam('jobid');
$stats = getdbolist('db_hashrenter', "time>{$t} and jobid=:jobid order by time", array(':jobid' => $jobid));
$averages = array();
echo '[[';
for ($i = $t + $step, $j = 0; $i < time(); $i += $step) {
    if ($i != $t + $step) {
        echo ',';
    }
    $m = 0;
    if ($i + $step >= time()) {
        $m = round(yaamp_job_rate($jobid) / 1000000, 3);
        //		debuglog("last $m");
    } else {
        if (isset($stats[$j]) && $i > $stats[$j]->time) {
            $m = round($stats[$j]->hashrate / 1000000, 3);
            $j++;
        }
    }
    $d = date('Y-m-d H:i:s', $i);
    echo "[\"{$d}\",{$m}]";
    $averages[] = array($d, $m);
}
echo '],[';
$average = $averages[0][1];
foreach ($averages as $i => $n) {
    if ($i) {
Esempio n. 4
0
 public function actionRental()
 {
     if (!LimitRequest('api-rental', 10)) {
         return;
     }
     $key = getparam('key');
     $renter = getdbosql('db_renters', "apikey=:apikey", array(':apikey' => $key));
     if (!$renter) {
         return;
     }
     $balance = bitcoinvaluetoa($renter->balance);
     $unconfirmed = bitcoinvaluetoa($renter->unconfirmed);
     echo "{";
     echo "\"balance\": {$balance}, ";
     echo "\"unconfirmed\": {$unconfirmed}, ";
     echo "\"jobs\": [";
     $list = getdbolist('db_jobs', "renterid={$renter->id}");
     foreach ($list as $i => $job) {
         if ($i) {
             echo ", ";
         }
         $hashrate = yaamp_job_rate($job->id);
         $hashrate_bad = yaamp_job_rate_bad($job->id);
         echo '{';
         echo "\"jobid\": \"{$job->id}\", ";
         echo "\"algo\": \"{$job->algo}\", ";
         echo "\"price\": \"{$job->price}\", ";
         echo "\"hashrate\": \"{$job->speed}\", ";
         echo "\"server\": \"{$job->host}\", ";
         echo "\"port\": \"{$job->port}\", ";
         echo "\"username\": \"{$job->username}\", ";
         echo "\"password\": \"{$job->password}\", ";
         echo "\"started\": \"{$job->ready}\", ";
         echo "\"active\": \"{$job->active}\", ";
         echo "\"accepted\": \"{$hashrate}\", ";
         echo "\"rejected\": \"{$hashrate_bad}\", ";
         echo "\"diff\": \"{$job->difficulty}\"";
         echo '}';
     }
     echo "]}";
 }
Esempio n. 5
0
echo "<tr>";
echo "<th></th>";
echo "<th>Server</th>";
echo "<th>Algo</th>";
echo "<th align=right>Max Price</th>";
//echo "<th>Current<br>Price</th>";
echo "<th align=right>Max Hash</th>";
echo "<th align=right>Hash*</th>";
echo "<th align=right>Diff</th>";
echo "<th></th>";
echo "</tr>";
echo "</thead><tbody>";
$list = getdbolist('db_jobs', "renterid={$renter->id} order by algo, price desc");
foreach ($list as $job) {
    $hashrate_bad = yaamp_job_rate_bad($job->id);
    $hashrate = yaamp_job_rate($job->id) + $hashrate_bad;
    $title_percent = '';
    if ($hashrate_bad) {
        $percent = round($hashrate_bad / $hashrate * 100, 1) . '%';
        $hashrate_bad = Itoa2($hashrate_bad) . 'h/s';
        $title_percent = "Rejected {$hashrate_bad} ({$percent})";
    }
    $hashrate = $hashrate ? Itoa2($hashrate) . 'h/s' : '';
    $maxhash = $job->speed ? Itoa2($job->speed) . 'h/s' : '';
    $title = "-o stratum+tcp://{$job->host}:{$job->port} -u {$job->username} -p {$job->password}";
    $servername = substr($job->host, 0, 22);
    $price = mbitcoinvaluetoa($job->price);
    $rent = dboscalar("select rent from hashrate where algo=:algo order by time desc limit 1", array(':algo' => $job->algo));
    $rent = mbitcoinvaluetoa($rent);
    $diff = $job->difficulty > 0 ? round($job->difficulty, 3) : '';
    if ($job->active) {