[UDPDATE] Put chain download into wrapper class

This commit is contained in:
Sebastian Grewe 2015-07-19 12:26:45 +02:00
parent 2c3052be24
commit b4ae900137
2 changed files with 14 additions and 8 deletions

View File

@ -66,6 +66,19 @@ class BitcoinWrapper extends BitcoinClient {
$dDifficulty = $this->getdifficulty();
return $this->memcache->setCache(__FUNCTION__, $dDifficulty * pow(2,32) / $iCurrentPoolHashrate, 30);
}
public function getblockchaindownload() {
$aPeerInfo = $this->getpeerinfo();
$aInfo = $this->getinfo();
$iStartingHeight = 0;
foreach ($aPeerInfo as $aPeerData) {
if ($iStartingHeight < $aPeerData['startingheight']) $iStartingHeight = $aPeerData['startingheight'];
}
if ($iStartingHeight > $aInfo['blocks']) {
return number_format(round($aInfo['blocks'] / $iStartingHeight * 100, 2), 2);
} else {
return false;
}
}
public function getnetworkhashps() {
$this->oDebug->append("STA " . __METHOD__, 4);
if ($data = $this->memcache->get(__FUNCTION__)) return $data;

View File

@ -24,14 +24,7 @@ if (!$smarty->isCached('master.tpl', $smarty_cache_key)) {
$aGetInfo = $bitcoin->getinfo();
$aGetPeerInfo = $bitcoin->getpeerinfo();
# Check if daemon is downloading the blockchain, estimated
$iStartingHeight = 0;
foreach ($aGetPeerInfo as $aPeerData) {
if ($iStartingHeight < $aPeerData['startingheight']) $iStartingHeight = $aPeerData['startingheight'];
}
if ($iStartingHeight > $aGetInfo['blocks']) {
$dDownloadPercentage = number_format(round($aGetInfo['blocks'] / $iStartingHeight * 100, 2), 2);
$aGetInfo['errors'] = "Downloading: $dDownloadPercentage%";
}
if ($dDownloadPercentage = $bitcoin->getblockchaindownload()) $aGetInfo['errors'] = "Downloading: $dDownloadPercentage%";
$aGetTransactions = $bitcoin->listtransactions('', (int)$setting->getValue('wallet_transaction_limit', 25));
if (is_array($aGetInfo) && array_key_exists('newmint', $aGetInfo)) {
$dNewmint = $aGetInfo['newmint'];