From abcd62d8e89feb5e35d9ea9e5b8bb9bf828655bb Mon Sep 17 00:00:00 2001 From: Sebastian Grewe Date: Wed, 25 Sep 2013 11:29:56 +0200 Subject: [PATCH] Fix #657, added getmininginfo to wrapper --- public/include/classes/bitcoinwrapper.class.php | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/public/include/classes/bitcoinwrapper.class.php b/public/include/classes/bitcoinwrapper.class.php index 7b4372b4..0c343c8a 100644 --- a/public/include/classes/bitcoinwrapper.class.php +++ b/public/include/classes/bitcoinwrapper.class.php @@ -46,9 +46,18 @@ class BitcoinWrapper extends BitcoinClient { 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; } + try { + $dNetworkHashrate = $this->query('getmininginfo'); + if (is_array($dNetworkHashrate) && array_key_exists('networkhashps', $dNetworkHashrate)) { + $dNetworkHashrate = $dNetworkHashrate['networkhashps']; + } else if (is_array($dNetworkHashrate) && array_key_exists('hashespersec', $dNetworkHashrate)) { + $dNetworkHashrate = $dNetworkHashrate['hashespersec']; + } + } catch (Exception $e) { + 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); }