fix _gettxoutsetinfo return type

This commit is contained in:
Akinwale Ariwodola 2020-01-07 23:37:50 +01:00
parent a147665e96
commit 77ca91757b

View file

@ -893,9 +893,8 @@ class MainController extends AppController {
$reservedtotal = $this->Addresses->find()->select(['balance' => 'SUM(balance)'])->where(['Addresses.address IN' => $allAddresses])->first(); $reservedtotal = $this->Addresses->find()->select(['balance' => 'SUM(balance)'])->where(['Addresses.address IN' => $allAddresses])->first();
$circulating = $txoutsetinfo->total_amount - ($reservedtotal->balance); $circulating = (isset($txoutsetinfo) ? $txoutsetinfo->total_amount : 0) - ($reservedtotal->balance);
return $this->_jsonResponse(['success' => true, 'utxosupply' => ['total' => isset($txoutsetinfo) ? $txoutsetinfo->total_amount : 0, 'circulating' => $circulating]]);
return $this->_jsonResponse(['success' => true, 'utxosupply' => ['total' => $txoutsetinfo->total_amount, 'circulating' => $circulating]]);
} }
protected function _formatHashRate($value) { protected function _formatHashRate($value) {
@ -1010,7 +1009,7 @@ class MainController extends AppController {
if ($cachedOutsetInfo !== false) { if ($cachedOutsetInfo !== false) {
$res = json_decode($cachedOutsetInfo); $res = json_decode($cachedOutsetInfo);
if (!isset($res->result)) { if (!isset($res->result)) {
return 0; return null;
} }
return $res->result; return $res->result;
} }
@ -1020,12 +1019,12 @@ class MainController extends AppController {
$response = self::curl_json_post(self::$rpcurl, json_encode($req)); $response = self::curl_json_post(self::$rpcurl, json_encode($req));
$res = json_decode($res); $res = json_decode($res);
if (!isset($res->result)) { if (!isset($res->result)) {
return 0; return null;
} }
Cache::write('gettxoutsetinfo', $response, 'api_requests'); Cache::write('gettxoutsetinfo', $response, 'api_requests');
return $res->result; return $res->result;
} catch (\Exception $e) { } catch (\Exception $e) {
return 0; return null;
} }
} }