本文整理汇总了PHP中dboscalar函数的典型用法代码示例。如果您正苦于以下问题:PHP dboscalar函数的具体用法?PHP dboscalar怎么用?PHP dboscalar使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了dboscalar函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: get_database_scalar
public function get_database_scalar($key, $query, $params = array())
{
$value = $this->get($key);
if ($value === false) {
$value = dboscalar($query, $params);
$this->set($key, $value);
}
return $value;
}
示例2: BackendQuickClean
function BackendQuickClean()
{
$delay = time() - 24 * 60 * 60;
$coins = getdbolist('db_coins', "installed");
foreach ($coins as $coin) {
$id = dboscalar("select id from blocks where coin_id={$coin->id} and time<{$delay} and\r\n\t\t\tid not in (select blockid from earnings where coinid={$coin->id})\r\n\t\t\torder by id desc limit 200, 1");
if ($id) {
dborun("delete from blocks where coin_id={$coin->id} and time<{$delay} and\r\n\t\t\tid not in (select blockid from earnings where coinid={$coin->id}) and id<{$id}");
}
}
dborun("delete from earnings where blockid in (select id from blocks where category='orphan')");
dborun("delete from earnings where blockid not in (select id from blocks)");
}
示例3: showUser
function showUser($userid, $what)
{
$user = getdbo('db_accounts', $userid);
if (!$user) {
return;
}
$d = datetoa2($user->last_login);
$balance = bitcoinvaluetoa($user->balance);
$paid = dboscalar("select sum(amount) from payouts where account_id={$user->id}");
$paid = bitcoinvaluetoa($paid);
$t = time() - 24 * 60 * 60;
$miner_count = getdbocount('db_workers', "userid={$user->id}");
$share_count = getdbocount('db_shares', "userid={$user->id}");
$block_count = getdbocount('db_blocks', "userid={$user->id} and time>{$t}");
$coin = getdbo('db_coins', $user->coinid);
echo "<tr class='ssrow'>";
if ($coin) {
echo "<td><img src='{$coin->image}' width=16> {$coin->symbol}</td>";
} else {
echo "<td></td>";
}
echo "<td>{$user->id}</td>";
echo "<td><a href='/site?address={$user->username}'>{$user->username}</a></td>";
echo "<td>{$what}</td>";
echo "<td>{$d}</td>";
echo "<td>{$block_count}</td>";
echo "<td>{$balance}</td>";
if (intval($paid) > 0.01) {
echo "<td><b>{$paid}</b></td>";
} else {
echo "<td>{$paid}</td>";
}
echo "<td>{$miner_count}</td>";
echo "<td>{$share_count}</td>";
if ($user->is_locked) {
echo "<td>locked</td>";
echo "<td><a href='/site/unblockuser?wallet={$user->username}'>unblock</a></td>";
} else {
echo "<td></td>";
echo "<td><a href='/site/blockuser?wallet={$user->username}'>block</a></td>";
}
echo "</tr>";
}
示例4: BackendBlockNew
function BackendBlockNew($coin, $db_block)
{
// debuglog("NEW BLOCK $coin->name $db_block->height");
$reward = $db_block->amount;
$total_hash_power = dboscalar("select sum(difficulty) from shares where valid and algo='{$coin->algo}'");
if (!$total_hash_power) {
return;
}
$list = dbolist("SELECT userid, sum(difficulty) as total from shares where valid and algo='{$coin->algo}' group by userid");
foreach ($list as $item) {
$hash_power = $item['total'];
if (!$hash_power) {
continue;
}
$user = getdbo('db_accounts', $item['userid']);
if (!$user) {
continue;
}
$amount = $reward * $hash_power / $total_hash_power;
if (!$user->no_fees) {
$amount = take_yaamp_fee($amount, $coin->algo);
}
$earning = new db_earnings();
$earning->userid = $user->id;
$earning->coinid = $coin->id;
$earning->blockid = $db_block->id;
$earning->create_time = $db_block->time;
$earning->amount = $amount;
$earning->price = $coin->price;
if ($db_block->category == 'generate') {
$earning->mature_time = time();
$earning->status = 1;
} else {
// immature
$earning->status = 0;
}
$earning->save();
$user->last_login = time();
$user->save();
}
$delay = time() - 5 * 60;
dborun("delete from shares where algo='{$coin->algo}' and time<{$delay}");
}
示例5: show_orders
}
echo "<td align=right style='font-size: .8em;'>{$pool_ttf}</td>";
echo "<td align=right style='font-size: .8em;'>{$pool_hash}</td>";
echo "<td align=right style='font-size: .8em;'><b>{$btcmhd}</b></td>";
echo "</tr>";
}
show_orders($allorders, $services);
show_services($services);
echo "</table><br>";
/////////////////////////////////////////////////////////////////////////////////////////////
$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\n\tworkerid 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\n\tworkerid 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: <b>{$total_nicehash} Gh/s</b> *** yaamp: ";
echo "<b>{$hashrate}</b> ";
echo "{$count} workers ";
echo "{$percent} ";
echo "</div></div><br>";
//////////////////////////////////////////////////////////////////////////////////////////////////
function show_services(&$services, $btcmhd = 0)
{
if (!controller()->admin || !$services) {
return;
示例6: BackendCoinPayments
function BackendCoinPayments($coin)
{
// debuglog("BackendCoinPayments $coin->symbol");
$remote = new Bitcoin($coin->rpcuser, $coin->rpcpasswd, $coin->rpchost, $coin->rpcport);
$info = $remote->getinfo();
if (!$info) {
debuglog("{$coin->symbol} cant connect to coin");
return;
}
$min = 0.001;
// if(date("w", time()) == 0 && date("H", time()) > 12) // sunday afternoon
// $min = 0.0001;
$users = getdbolist('db_accounts', "balance>{$min} and coinid={$coin->id}");
if ($coin->symbol == 'MUE' || $coin->symbol == 'DIME') {
foreach ($users as $user) {
$user = getdbo('db_accounts', $user->id);
if (!$user) {
continue;
}
$amount = $user->balance;
while ($user->balance > $min && $amount > $min) {
debuglog("{$coin->symbol} sendtoaddress {$user->username} {$amount}");
$tx = $remote->sendtoaddress($user->username, round($amount, 8));
if (!$tx) {
debuglog("error {$remote->error}, {$user->username}, {$amount}");
if ($remote->error == 'transaction too large' || $remote->error == 'invalid amount') {
$amount /= 2;
continue;
}
break;
}
$payout = new db_payouts();
$payout->account_id = $user->id;
$payout->time = time();
$payout->amount = bitcoinvaluetoa($amount);
$payout->fee = 0;
$payout->tx = $tx;
$payout->save();
$user->balance -= $amount;
$user->save();
}
}
debuglog("payment done");
return;
}
$total_to_pay = 0;
$addresses = array();
foreach ($users as $user) {
$total_to_pay += round($user->balance, 8);
$addresses[$user->username] = round($user->balance, 8);
}
if (!$total_to_pay) {
// debuglog("nothing to pay");
return;
}
if ($info['balance'] - 0.001 < $total_to_pay) {
debuglog("{$coin->symbol} wallet insufficient funds for payment {$info['balance']} < {$total_to_pay}");
return;
}
if ($coin->symbol == 'BTC') {
global $cold_wallet_table;
$balance = $info['balance'];
$stats = getdbosql('db_stats', "1 order by time desc");
$renter = dboscalar("select sum(balance) from renters");
$pie = $balance - $total_to_pay - $renter - 1;
debuglog("pie to split is {$pie}");
if ($pie > 0) {
foreach ($cold_wallet_table as $coldwallet => $percent) {
$coldamount = round($pie * $percent, 8);
if ($coldamount < $min) {
break;
}
debuglog("paying cold wallet {$coldwallet} {$coldamount}");
$addresses[$coldwallet] = $coldamount;
$total_to_pay += $coldamount;
}
}
}
debuglog("paying {$total_to_pay} {$coin->symbol} min is {$min}");
$tx = $remote->sendmany('', $addresses, 1, '');
if (!$tx) {
debuglog($remote->error);
return;
}
foreach ($users as $user) {
$user = getdbo('db_accounts', $user->id);
if (!$user) {
continue;
}
$payout = new db_payouts();
$payout->account_id = $user->id;
$payout->time = time();
$payout->amount = bitcoinvaluetoa($user->balance);
$payout->fee = 0;
$payout->tx = $tx;
$payout->save();
$user->balance = 0;
$user->save();
}
debuglog("payment done");
//.........这里部分代码省略.........
示例7: getdbolist
echo "<thead>";
echo "<tr>";
echo "<th>Renter</th>";
echo "<th>Address</th>";
echo "<th>Email</th>";
echo "<th>Spent</th>";
echo "<th>Balance</th>";
echo "<th>Unconfirmed</th>";
echo "<th>Jobs</th>";
echo "<th>Active</th>";
echo "</tr>";
echo "</thead><tbody>";
$list = getdbolist('db_renters', "balance>0 order by balance desc");
foreach ($list as $renter) {
$count = dboscalar("select count(*) from jobs where renterid={$renter->id}");
$active = dboscalar("select count(*) from jobs where renterid={$renter->id} and active");
if ($deposit == $renter->address) {
echo "<tr class='ssrow' style='background-color: #dfd'>";
} else {
echo "<tr class='ssrow'>";
}
echo "<td>{$renter->id}</td>";
echo "<td><a href='/renting?address={$renter->address}'>{$renter->address}</a></td>";
echo "<td>{$renter->email}</td>";
echo "<td>{$renter->spent}</td>";
echo "<td>{$renter->balance}</td>";
echo "<td>{$renter->unconfirmed}</td>";
echo "<td>{$count}</td>";
echo "<td>{$active}</td>";
echo "</tr>";
}
示例8: sellCoinToExchange
function sellCoinToExchange($coin)
{
if ($coin->dontsell) {
return;
}
$remote = new Bitcoin($coin->rpcuser, $coin->rpcpasswd, $coin->rpchost, $coin->rpcport);
$info = $remote->getinfo();
if (!$info || !$info['balance']) {
return false;
}
if (!empty($coin->symbol2)) {
$coin2 = getdbosql('db_coins', "symbol='{$coin->symbol2}'");
if (!$coin2) {
return;
}
$amount = $info['balance'] - $info['paytxfee'];
$amount *= 0.9;
// debuglog("sending $amount $coin->symbol to main wallet");
$tx = $remote->sendtoaddress($coin2->master_wallet, $amount);
// if(!$tx) debuglog($remote->error);
return;
}
$market = getBestMarket($coin);
if (!$market) {
return;
}
if (!$coin->sellonbid && $market->lastsent != null && $market->lastsent > $market->lasttraded) {
// debuglog("*** not sending $coin->name to $market->name. last tx is late ***");
return;
}
$deposit_address = $market->deposit_address;
$marketname = $market->name;
if (empty($deposit_address)) {
return false;
}
$reserved1 = dboscalar("select sum(balance) from accounts where coinid={$coin->id}");
$reserved2 = dboscalar("select sum(amount*price) from earnings\n\t\twhere status!=2 and userid in (select id from accounts where coinid={$coin->id})");
$reserved = ($reserved1 + $reserved2) * 10;
$amount = $info['balance'] - $info['paytxfee'] - $reserved;
// if($reserved>0)
// {
// debuglog("$reserved1 $reserved2 out of {$info['balance']}");
// debuglog("reserving $reserved $coin->symbol out of $coin->balance, available $amount");
// }
if ($amount < $coin->reward / 4) {
// debuglog("not enough $coin->symbol to sell $amount < $coin->reward /4");
return false;
}
$deposit_info = $remote->validateaddress($deposit_address);
if (!$deposit_info || !isset($deposit_info['isvalid']) || !$deposit_info['isvalid']) {
debuglog("sell invalid address {$deposit_address}");
return;
}
$amount = round($amount, 8);
// debuglog("sending $amount $coin->symbol to $marketname, $deposit_address");
$market->lastsent = time();
$market->save();
// sleep(1);
$tx = $remote->sendtoaddress($deposit_address, $amount);
if (!$tx) {
// debuglog($remote->error);
if ($coin->symbol == 'MUE') {
$amount = min($amount, 5000);
} else {
if ($coin->symbol == 'DIME') {
$amount = min($amount, 10000000);
} else {
if ($coin->symbol == 'CNOTE') {
$amount = min($amount, 10000);
} else {
if ($coin->symbol == 'SRC') {
$amount = min($amount, 500);
} else {
$amount = round($amount * 0.99, 8);
}
}
}
}
// debuglog("sending $amount $coin->symbol to $deposit_address");
sleep(1);
$tx = $remote->sendtoaddress($deposit_address, $amount);
if (!$tx) {
debuglog("sending {$amount} {$coin->symbol} to {$deposit_address}");
debuglog($remote->error);
return;
}
}
$exchange = new db_exchange();
$exchange->market = $marketname;
$exchange->coinid = $coin->id;
$exchange->send_time = time();
$exchange->quantity = $amount;
$exchange->price_estimate = $coin->price;
$exchange->status = 'waiting';
$exchange->tx = $tx;
$exchange->save();
return;
}
示例9: foreach
$total_balance = 0;
$total_paid = 0;
$total_unsold = 0;
foreach ($users as $user) {
$target = yaamp_hashrate_constant();
$interval = yaamp_hashrate_step();
$delay = time() - $interval;
$user_rate = dboscalar("select sum(difficulty) * {$target} / {$interval} / 1000 from shares where valid and time>{$delay} and userid={$user->id}");
$user_bad = dboscalar("select sum(difficulty) * {$target} / {$interval} / 1000 from shares where not valid and time>{$delay} and userid={$user->id}");
$percent = $user_rate ? round($user_bad * 100 / $user_rate, 3) : 0;
$balance = bitcoinvaluetoa($user->balance);
$paid = dboscalar("select sum(amount) from payouts where account_id={$user->id}");
$d = datetoa2($user->last_login);
$miner_count = getdbocount('db_workers', "userid={$user->id}");
$block_count = getdbocount('db_blocks', "userid={$user->id}");
$block_diff = $paid ? round(dboscalar("select sum(difficulty) from blocks where userid={$user->id}") / $paid, 3) : '?';
$paid = bitcoinvaluetoa($paid);
$user_rate = Itoa2($user_rate);
$user_bad = Itoa2($user_bad);
echo "<tr class='ssrow'>";
echo "<td>{$user->id}</td>";
echo "<td><a href='/?address={$user->username}'><b>{$user->username}</b></a></td>";
echo "<td>{$d}</td>";
echo "<td align=right>{$miner_count}</td>";
echo "<td align=right>{$user_rate}</td>";
echo "<td align=right>{$user_bad}</td>";
if ($percent > 50) {
echo "<td align=right><b>{$percent}%</b></td>";
} else {
echo "<td align=right>{$percent}%</td>";
}
示例10: yaamp_convert_earnings_user
function yaamp_convert_earnings_user($user, $status)
{
$refcoin = getdbo('db_coins', $user->coinid);
if (!$refcoin) {
$refcoin = getdbosql('db_coins', "symbol='BTC'");
}
if (!$refcoin || $refcoin->price2 <= 0) {
return 0;
}
$value = dboscalar("select sum(amount*price) from earnings where {$status} and userid={$user->id}");
$value = $value / $refcoin->price2;
return $value;
}
示例11: dboscalar
<?php
$last = dboscalar("select max(last) from connections");
$list = getdbolist('db_connections', "1 order by id desc");
echo count($list) . " connections<br>";
//echo "<table class='dataGrid'>";
showTableSorter('maintable');
echo "<thead>";
echo "<tr>";
echo "<th>ID</th>";
echo "<th>User</th>";
echo "<th>Host</th>";
echo "<th>Db</th>";
echo "<th>Idle</th>";
echo "<th>Created</th>";
echo "<th>Last</th>";
echo "<th></th>";
echo "</tr>";
echo "</thead><tbody>";
foreach ($list as $conn) {
echo "<tr class='ssrow'>";
$d1 = sectoa($conn->idle);
$d2 = datetoa2($conn->created);
$d3 = datetoa2($conn->last);
$b = Booltoa($conn->last == $last);
echo "<td>{$conn->id}</td>";
echo "<td>{$conn->user}</td>";
echo "<td>{$conn->host}</td>";
echo "<td>{$conn->db}</td>";
echo "<td>{$d1}</td>";
echo "<td>{$d2}</td>";
示例12: getdbo
<?php
$coin = getdbo('db_coins', $_GET['id']);
$remote = new Bitcoin($coin->rpcuser, $coin->rpcpasswd, $coin->rpchost, $coin->rpcport);
$reserved1 = dboscalar("select sum(balance) from accounts where coinid={$coin->id}");
$reserved2 = dboscalar("select sum(amount*price) from earnings\n\twhere status!=2 and userid in (select id from accounts where coinid={$coin->id})");
$reserved = ($reserved1 + $reserved2) * 2;
$owed = dboscalar("select sum(amount) from earnings where status!=2 and coinid={$coin->id}");
$owed_btc = $owed ? bitcoinvaluetoa($owed * $coin->price) : '';
$owed = $owed ? altcoinvaluetoa($owed) : '';
echo "cleared {$reserved1}, earnings {$reserved2}, reserved {$reserved}, balance {$coin->balance}, owed {$owed}, owned btc {$owed_btc}<br><br>";
//////////////////////////////////////////////////////////////////////////////////////
$list = getdbolist('db_markets', "coinid={$coin->id} order by price desc");
echo "<table class='dataGrid'>";
echo "<thead class=''>";
echo "<tr>";
echo "<th>Name</th>";
echo "<th>Price</th>";
echo "<th>Price2</th>";
echo "<th>Sent</th>";
echo "<th>Traded</th>";
echo "<th>Late</th>";
echo "<th>Deposit</th>";
echo "<th>Message</th>";
echo "</tr>";
echo "</thead><tbody>";
$bestmarket = getBestMarket($coin);
foreach ($list as $market) {
$price = bitcoinvaluetoa($market->price);
$price2 = bitcoinvaluetoa($market->price2);
$lowsymbol = strtolower($coin->symbol);
示例13: sectoa
$loop2_time = sectoa(time() - memcache_get($this->memcache->memcache, "cronjob_loop2_time_start"));
$main_time2 = sectoa(time() - memcache_get($this->memcache->memcache, "cronjob_main_time_start"));
$main_time = sectoa(memcache_get($this->memcache->memcache, "cronjob_main_time"));
$main_text = cronstate2text($state_main);
echo "*** main ({$main_time}) {$state_main} {$main_text} ({$main_time2}), loop2 ({$loop2_time}), block ({$block_time})<br>";
$topay = dboscalar("select sum(balance) from accounts where coinid={$btc->id}");
//here: take other currencies too
$topay2 = bitcoinvaluetoa(dboscalar("select sum(balance) from accounts where coinid={$btc->id} and balance>0.001"));
$renter = dboscalar("select sum(balance) from renters");
$stats = getdbosql('db_stats', "1 order by time desc");
$margin2 = bitcoinvaluetoa($btc->balance - $topay - $renter + $stats->balances + $stats->onsell + $stats->wallets);
$margin = bitcoinvaluetoa($btc->balance - $topay - $renter);
$topay = bitcoinvaluetoa($topay);
$renter = bitcoinvaluetoa($renter);
$immature = dboscalar("select sum(amount*price) from earnings where status=0");
$mints = dboscalar("select sum(mint*price) from coins where enable");
$off = $mints - $immature;
$immature = bitcoinvaluetoa($immature);
$mints = bitcoinvaluetoa($mints);
$off = bitcoinvaluetoa($off);
$btcaddr = YAAMP_BTCADDRESS;
//'14LS7Uda6EZGXLtRrFEZ2kWmarrxobkyu9';
echo "<a href='https://www.okcoin.com/market.do' target=_blank>Bitstamp {$mining->usdbtc}</a>, ";
echo "<a href='https://blockchain.info/address/{$btcaddr}' target=_blank>wallet {$btc->balance}</a>, next payout {$topay2}<br>";
echo "pay {$topay}, renter {$renter}, marg {$margin}, {$margin2}<br>";
echo "mint {$mints} immature {$immature} off {$off}<br>";
echo '<br>';
//////////////////////////////////////////////////////////////////////////////////////////////////
echo "<div style='height: 160px;' id='graph_results_negative'></div>";
//echo "<div style='height: 160px;' id='graph_results_profit'></div>";
echo "<div style='height: 200px;' id='graph_results_assets'></div>";
示例14: BackendUpdateServices
function BackendUpdateServices()
{
// debuglog(__FUNCTION__);
$table = array(0 => 'scrypt', 1 => 'sha256', 2 => 'scryptn', 3 => 'x11', 4 => 'x13', 5 => 'keccak', 6 => 'x15', 7 => 'nist5', 8 => 'neoscrypt', 9 => 'lyra2', 10 => 'whirlx', 11 => 'qubit', 12 => 'quark', 111 => 'c11');
$res = fetch_url('https://www.nicehash.com/api?method=stats.global.current');
if (!$res) {
return;
}
$a = json_decode($res);
if (!$a || !isset($a->result)) {
return;
}
foreach ($a->result->stats as $stat) {
if ($stat->price <= 0) {
continue;
}
if (!isset($table[$stat->algo])) {
continue;
}
$algo = $table[$stat->algo];
$service = getdbosql('db_services', "name='Nicehash' and algo=:algo", array(':algo' => $algo));
if (!$service) {
$service = new db_services();
$service->name = 'Nicehash';
$service->algo = $algo;
}
$service->price = $stat->price / 1000;
$service->speed = $stat->speed * 1000000000;
$service->save();
$list = getdbolist('db_jobs', "percent>0 and algo=:algo and (host='stratum.westhash.com' or host='stratum.nicehash.com')", array(':algo' => $algo));
foreach ($list as $job) {
$job->price = round($service->price * 1000 * (100 - $job->percent) / 100, 2);
$job->save();
}
}
$list = getdbolist('db_renters', "custom_address is not null and custom_server is not null");
foreach ($list as $renter) {
$res = fetch_url("https://{$renter->custom_server}/api?method=stats.provider&addr={$renter->custom_address}");
if (!$res) {
continue;
}
$renter->custom_balance = 0;
$renter->custom_accept = 0;
$renter->custom_reject = 0;
$a = json_decode($res);
foreach ($a->result->stats as $stat) {
if (!isset($table[$stat->algo])) {
continue;
}
$algo = $table[$stat->algo];
$renter->custom_balance += $stat->balance;
$renter->custom_accept += $stat->accepted_speed * 1000000000;
$renter->custom_reject += $stat->rejected_speed * 1000000000;
}
$renter->save();
}
///////////////////////////////////////////////////////////////////////////
// renting from nicehash
if (!YAAMP_PRODUCTION) {
return;
}
return;
$apikey = 'c9534a11-0e4e-4d00-be64-a00e34cd927a';
$apiid = '7215';
$deposit = '1C23KmLeCaQSLLyKVykHEUse1R7jRDv9j9';
$amount = '0.01';
$res = fetch_url("https://www.nicehash.com/api?method=balance&id={$apiid}&key={$apikey}");
$a = json_decode($res);
$balance = $a->result->balance_confirmed;
foreach ($table as $i => $algo) {
$nicehash = getdbosql('db_nicehash', "algo=:algo", array(':algo' => $algo));
if (!$nicehash) {
$nicehash = new db_nicehash();
$nicehash->active = false;
$nicehash->algo = $algo;
}
if (!$nicehash->active) {
if ($nicehash->orderid) {
$res = fetch_url("https://www.nicehash.com/api?method=orders.remove&id={$apiid}&key={$apikey}&algo={$i}&order={$nicehash->orderid}");
debuglog($res);
$nicehash->orderid = null;
}
$nicehash->btc = null;
$nicehash->price = null;
$nicehash->speed = null;
$nicehash->last_decrease = null;
$nicehash->save();
continue;
}
$price = dboscalar("select price from hashrate where algo=:algo order by time desc limit 1", array(':algo' => $algo));
$minprice = $price * 0.5;
$setprice = $price * 0.7;
$maxprice = $price * 0.9;
$cancelprice = $price * 1.1;
$res = fetch_url("https://www.nicehash.com/api?method=orders.get&my&id={$apiid}&key={$apikey}&algo={$i}");
if (!$res) {
break;
}
$a = json_decode($res);
if (count($a->result->orders) == 0) {
//.........这里部分代码省略.........
示例15: BackendCoinsUpdate
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;
}
}
//.........这里部分代码省略.........