diff --git a/include/classes/bitcoinwrapper.class.php b/include/classes/bitcoinwrapper.class.php index 3679ee43..16232e4d 100644 --- a/include/classes/bitcoinwrapper.class.php +++ b/include/classes/bitcoinwrapper.class.php @@ -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; diff --git a/include/pages/admin/wallet.inc.php b/include/pages/admin/wallet.inc.php index 9738324e..25461b49 100644 --- a/include/pages/admin/wallet.inc.php +++ b/include/pages/admin/wallet.inc.php @@ -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'];