fix custom configuration loading and gettxoutsetinfo request

This commit is contained in:
Akinwale Ariwodola 2020-01-08 22:02:03 +01:00
parent a7c1b9b346
commit 52d13987e5
2 changed files with 8 additions and 10 deletions

View file

@ -226,5 +226,4 @@ if (Configure::read('debug')) {
Application::addPlugin('DebugKit', ['bootstrap' => true]); Application::addPlugin('DebugKit', ['bootstrap' => true]);
} }
Configure::load('lbry','lbry.default'); Configure::load('lbry', 'default');

View file

@ -19,7 +19,7 @@ use Endroid\QrCode\Response\QrCodeResponse;
class MainController extends AppController { class MainController extends AppController {
public static $rpcurl; protected $rpcurl;
const lbcPriceKey = 'lbc.price'; const lbcPriceKey = 'lbc.price';
@ -37,7 +37,7 @@ class MainController extends AppController {
public function initialize() { public function initialize() {
parent::initialize(); parent::initialize();
self::$rpcurl = Configure::read('Lbry.RpcUrl'); $this->rpcurl = Configure::read('Lbry.RpcUrl');
$this->redis = new \Predis\Client(Configure::read('Redis.Url')); $this->redis = new \Predis\Client(Configure::read('Redis.Url'));
try { try {
$this->redis->info('mem'); $this->redis->info('mem');
@ -943,7 +943,7 @@ class MainController extends AppController {
private function _gethashrate() { private function _gethashrate() {
$req = ['method' => 'getnetworkhashps', 'params' => []]; $req = ['method' => 'getnetworkhashps', 'params' => []];
try { 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)) { if (!isset($res->result)) {
return 0; return 0;
} }
@ -1008,16 +1008,15 @@ class MainController extends AppController {
$cachedOutsetInfo = Cache::read('gettxoutsetinfo', 'api_requests'); $cachedOutsetInfo = Cache::read('gettxoutsetinfo', 'api_requests');
if ($cachedOutsetInfo !== false) { if ($cachedOutsetInfo !== false) {
$res = json_decode($cachedOutsetInfo); $res = json_decode($cachedOutsetInfo);
if (!isset($res->result)) { if (isset($res->result)) {
return null; return $res->result;
} }
return $res->result;
} }
$req = ['method' => 'gettxoutsetinfo', 'params' => []]; $req = ['method' => 'gettxoutsetinfo', 'params' => []];
try { try {
$response = self::curl_json_post(self::$rpcurl, json_encode($req)); $response = self::curl_json_post($this->rpcurl, json_encode($req));
$res = json_decode($res); $res = json_decode($response);
if (!isset($res->result)) { if (!isset($res->result)) {
return null; return null;
} }