Merge branch 'next' into issue-444-theserapher
This commit is contained in:
commit
e88d80cd02
@ -25,19 +25,32 @@ class BitcoinWrapper extends BitcoinClient {
|
||||
public function getblockcount() {
|
||||
$this->oDebug->append("STA " . __METHOD__, 4);
|
||||
if ($data = $this->memcache->get(__FUNCTION__)) return $data;
|
||||
return $this->memcache->setCache(__FUNCTION__, parent::getblockcount());
|
||||
return $this->memcache->setCache(__FUNCTION__, parent::getblockcount(), 30);
|
||||
}
|
||||
public function getdifficulty() {
|
||||
$this->oDebug->append("STA " . __METHOD__, 4);
|
||||
if ($data = $this->memcache->get(__FUNCTION__)) return $data;
|
||||
return $this->memcache->setCache(__FUNCTION__, parent::getdifficulty());
|
||||
$data = parent::getdifficulty();
|
||||
// Check for PoS/PoW coins
|
||||
if (is_array($data) && array_key_exists('proof-of-work', $data))
|
||||
$data = $data['proof-of-work'];
|
||||
return $this->memcache->setCache(__FUNCTION__, $data, 30);
|
||||
}
|
||||
public function getestimatedtime($iCurrentPoolHashrate) {
|
||||
$this->oDebug->append("STA " . __METHOD__, 4);
|
||||
if ($iCurrentPoolHashrate == 0) return 0;
|
||||
if ($data = $this->memcache->get(__FUNCTION__)) return $data;
|
||||
$dDifficulty = parent::getdifficulty();
|
||||
return $this->memcache->setCache(__FUNCTION__, $dDifficulty * pow(2,32) / $iCurrentPoolHashrate);
|
||||
$dDifficulty = $this->getdifficulty();
|
||||
return $this->memcache->setCache(__FUNCTION__, $dDifficulty * pow(2,32) / $iCurrentPoolHashrate, 30);
|
||||
}
|
||||
public function getnetworkhashps() {
|
||||
$this->oDebug->append("STA " . __METHOD__, 4);
|
||||
if ($data = $this->memcache->get(__FUNCTION__)) return $data;
|
||||
try { $dNetworkHashrate = $this->query('getnetworkhashps') / 1000; } catch (Exception $e) {
|
||||
// Maybe we are SHA
|
||||
try { $dNetworkHashrate = $this->query('gethashespersec') / 1000; } catch (Exception $e) { return false; }
|
||||
}
|
||||
return $this->memcache->setCache(__FUNCTION__, $dNetworkHashrate, 30);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -11,12 +11,7 @@ $id = $user->checkApiKey($_REQUEST['api_key']);
|
||||
|
||||
// Fetch data from wallet
|
||||
if ($bitcoin->can_connect() === true){
|
||||
if (!$dDifficulty = $memcache->get('dDifficulty')) {
|
||||
$dDifficulty = $bitcoin->query('getdifficulty');
|
||||
if (is_array($dDifficulty) && array_key_exists('proof-of-work', $dDifficulty))
|
||||
$dDifficulty = $dDifficulty['proof-of-work'];
|
||||
$memcache->set('dDifficulty', $dDifficulty);
|
||||
}
|
||||
$dDifficulty = $bitcoin->getdifficulty();
|
||||
} else {
|
||||
$iDifficulty = 1;
|
||||
}
|
||||
|
||||
@ -19,8 +19,6 @@ $aShares['valid'] > 0 ? $dEfficiency = round((100 - (100 / $aShares['valid'] * $
|
||||
// Fetch RPC data
|
||||
if ($bitcoin->can_connect() === true){
|
||||
$dDifficulty = $bitcoin->getdifficulty();
|
||||
if (is_array($dDifficulty) && array_key_exists('proof-of-work', $dDifficulty))
|
||||
$dDifficulty = $dDifficulty['proof-of-work'];
|
||||
$iBlock = $bitcoin->getblockcount();
|
||||
$dNetworkHashrate = $bitcoin->query('getnetworkhashps');
|
||||
} else {
|
||||
|
||||
@ -11,7 +11,7 @@ $aLastBlock = $block->getLast();
|
||||
$aShares = $statistics->getRoundShares();
|
||||
|
||||
// RPC Calls
|
||||
$bitcoin->can_connect() === true ? $dNetworkHashrate = $bitcoin->query('getnetworkhashps') : $dNetworkHashrate = 0;
|
||||
$bitcoin->can_connect() === true ? $dNetworkHashrate = $bitcoin->getnetworkhashps() : $dNetworkHashrate = 0;
|
||||
|
||||
echo json_encode(
|
||||
array(
|
||||
|
||||
@ -7,9 +7,7 @@ if (!defined('SECURITY'))
|
||||
if (!$smarty->isCached('master.tpl', $smarty_cache_key)) {
|
||||
$debug->append('No cached version available, fetching from backend', 3);
|
||||
if ($bitcoin->can_connect() === true){
|
||||
$dDifficulty = $bitcoin->query('getdifficulty');
|
||||
if (is_array($dDifficulty) && array_key_exists('proof-of-work', $dDifficulty))
|
||||
$dDifficulty = $dDifficulty['proof-of-work'];
|
||||
$dDifficulty = $bitcoin->getdifficulty();
|
||||
$iBlock = $bitcoin->query('getblockcount');
|
||||
} else {
|
||||
$dDifficulty = 1;
|
||||
|
||||
@ -8,8 +8,6 @@ if (!$smarty->isCached('master.tpl', $smarty_cache_key)) {
|
||||
// Fetch data from wallet
|
||||
if ($bitcoin->can_connect() === true){
|
||||
$dDifficulty = $bitcoin->getdifficulty();
|
||||
if (is_array($dDifficulty) && array_key_exists('proof-of-work', $dDifficulty))
|
||||
$dDifficulty = $dDifficulty['proof-of-work'];
|
||||
$iBlock = $bitcoin->getblockcount();
|
||||
is_int($iBlock) && $iBlock > 0 ? $sBlockHash = $bitcoin->query('getblockhash', $iBlock) : $sBlockHash = '';
|
||||
} else {
|
||||
|
||||
@ -14,17 +14,10 @@ $aRoundShares = 1;
|
||||
// Only run these if the user is logged in
|
||||
$aRoundShares = $statistics->getRoundShares();
|
||||
if ($bitcoin->can_connect() === true) {
|
||||
$dDifficulty = $bitcoin->query('getdifficulty');
|
||||
if (is_array($dDifficulty) && array_key_exists('proof-of-work', $dDifficulty))
|
||||
$dDifficulty = $dDifficulty['proof-of-work'];
|
||||
try { $dNetworkHashrate = $bitcoin->query('getnetworkhashps') / 1000; } catch (Exception $e) {
|
||||
// Maybe we are SHA
|
||||
try { $dNetworkHashrate = $bitcoin->query('gethashespersec') / 1000; } catch (Exception $e) {
|
||||
$dNetworkHashrate = 0;
|
||||
}
|
||||
$dNetworkHashrate = 0;
|
||||
}
|
||||
$dDifficulty = $bitcoin->getdifficulty();
|
||||
$dNetworkHashrate = $bitcoin->getnetworkhashps();
|
||||
} else {
|
||||
$dDifficulty = 0;
|
||||
$dNetworkHashrate = 0;
|
||||
}
|
||||
|
||||
|
||||
Loading…
Reference in New Issue
Block a user