From 52d13987e5b6cc87b7262d1e8790d92385420c20 Mon Sep 17 00:00:00 2001 From: Akinwale Ariwodola Date: Wed, 8 Jan 2020 22:02:03 +0100 Subject: [PATCH] fix custom configuration loading and gettxoutsetinfo request --- config/bootstrap.php | 3 +-- src/Controller/MainController.php | 15 +++++++-------- 2 files changed, 8 insertions(+), 10 deletions(-) diff --git a/config/bootstrap.php b/config/bootstrap.php index 756de4d..871b6f8 100644 --- a/config/bootstrap.php +++ b/config/bootstrap.php @@ -226,5 +226,4 @@ if (Configure::read('debug')) { Application::addPlugin('DebugKit', ['bootstrap' => true]); } -Configure::load('lbry','lbry.default'); - +Configure::load('lbry', 'default'); diff --git a/src/Controller/MainController.php b/src/Controller/MainController.php index 29660ea..3e7ec77 100644 --- a/src/Controller/MainController.php +++ b/src/Controller/MainController.php @@ -19,7 +19,7 @@ use Endroid\QrCode\Response\QrCodeResponse; class MainController extends AppController { - public static $rpcurl; + protected $rpcurl; const lbcPriceKey = 'lbc.price'; @@ -37,7 +37,7 @@ class MainController extends AppController { public function initialize() { parent::initialize(); - self::$rpcurl = Configure::read('Lbry.RpcUrl'); + $this->rpcurl = Configure::read('Lbry.RpcUrl'); $this->redis = new \Predis\Client(Configure::read('Redis.Url')); try { $this->redis->info('mem'); @@ -943,7 +943,7 @@ class MainController extends AppController { private function _gethashrate() { $req = ['method' => 'getnetworkhashps', 'params' => []]; try { - $res = json_decode(self::curl_json_post(self::$rpcurl, json_encode($req))); + $res = json_decode(self::curl_json_post($this->rpcurl, json_encode($req))); if (!isset($res->result)) { return 0; } @@ -1008,16 +1008,15 @@ class MainController extends AppController { $cachedOutsetInfo = Cache::read('gettxoutsetinfo', 'api_requests'); if ($cachedOutsetInfo !== false) { $res = json_decode($cachedOutsetInfo); - if (!isset($res->result)) { - return null; + if (isset($res->result)) { + return $res->result; } - return $res->result; } $req = ['method' => 'gettxoutsetinfo', 'params' => []]; try { - $response = self::curl_json_post(self::$rpcurl, json_encode($req)); - $res = json_decode($res); + $response = self::curl_json_post($this->rpcurl, json_encode($req)); + $res = json_decode($response); if (!isset($res->result)) { return null; }