move RPC URL value to configuration file
This commit is contained in:
parent
27ff22ff5a
commit
71c7834521
6 changed files with 34 additions and 23 deletions
1
.gitignore
vendored
1
.gitignore
vendored
|
@ -1,5 +1,6 @@
|
||||||
/vendor/*
|
/vendor/*
|
||||||
/config/app.php
|
/config/app.php
|
||||||
|
/config/lbry.php
|
||||||
/logs/*
|
/logs/*
|
||||||
lbryexplorer.zip
|
lbryexplorer.zip
|
||||||
lbryexplorer.komodoproject
|
lbryexplorer.komodoproject
|
||||||
|
|
|
@ -220,3 +220,6 @@ Type::build('timestamp')
|
||||||
if (Configure::read('debug')) {
|
if (Configure::read('debug')) {
|
||||||
Plugin::load('DebugKit', ['bootstrap' => true]);
|
Plugin::load('DebugKit', ['bootstrap' => true]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Configure::load('lbry');
|
||||||
|
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
#!/bin/sh
|
#!/bin/sh
|
||||||
cd /home/lbry/explorer.lbry.io
|
cd /home/lbry/explorer.lbry.io
|
||||||
bin/cake block parsenewblocks
|
bin/cake block parsenewblocks
|
||||||
rm tmp/lock/parsenewblocks
|
rm tmp/lock/parsenewblocks 2>/dev/null
|
||||||
bin/cake block parsetxs
|
bin/cake block parsetxs
|
||||||
rm tmp/lock/parsetxs
|
rm tmp/lock/parsetxs 2>/dev/null
|
||||||
|
|
||||||
|
|
|
@ -7,6 +7,7 @@ use Mdanter\Ecc\Crypto\Signature\Signer;
|
||||||
use Mdanter\Ecc\Serializer\PublicKey\PemPublicKeySerializer;
|
use Mdanter\Ecc\Serializer\PublicKey\PemPublicKeySerializer;
|
||||||
use Mdanter\Ecc\Serializer\PublicKey\DerPublicKeySerializer;
|
use Mdanter\Ecc\Serializer\PublicKey\DerPublicKeySerializer;
|
||||||
use Mdanter\Ecc\Serializer\Signature\DerSignatureSerializer;
|
use Mdanter\Ecc\Serializer\Signature\DerSignatureSerializer;
|
||||||
|
use Cake\Core\Configure;
|
||||||
use Cake\Datasource\ConnectionManager;
|
use Cake\Datasource\ConnectionManager;
|
||||||
use Cake\Log\Log;
|
use Cake\Log\Log;
|
||||||
use Endroid\QrCode\ErrorCorrectionLevel;
|
use Endroid\QrCode\ErrorCorrectionLevel;
|
||||||
|
@ -15,7 +16,7 @@ use Endroid\QrCode\QrCode;
|
||||||
|
|
||||||
class MainController extends AppController {
|
class MainController extends AppController {
|
||||||
|
|
||||||
const rpcurl = 'http://lrpc:lrpc@127.0.0.1:9245';
|
public static $rpcurl;
|
||||||
|
|
||||||
const lbcPriceKey = 'lbc.price';
|
const lbcPriceKey = 'lbc.price';
|
||||||
|
|
||||||
|
@ -29,6 +30,7 @@ class MainController extends AppController {
|
||||||
|
|
||||||
public function initialize() {
|
public function initialize() {
|
||||||
parent::initialize();
|
parent::initialize();
|
||||||
|
self::$rpcurl = Configure::read('Lbry.RpcUrl');
|
||||||
$this->redis = new \Predis\Client('tcp://127.0.0.1:6379');
|
$this->redis = new \Predis\Client('tcp://127.0.0.1:6379');
|
||||||
try {
|
try {
|
||||||
$this->redis->info('mem');
|
$this->redis->info('mem');
|
||||||
|
@ -421,7 +423,7 @@ class MainController extends AppController {
|
||||||
try {
|
try {
|
||||||
// update the block confirmations
|
// update the block confirmations
|
||||||
$req = ['method' => 'getblock', 'params' => [$block->Hash]];
|
$req = ['method' => 'getblock', 'params' => [$block->Hash]];
|
||||||
$response = self::curl_json_post(self::rpcurl, json_encode($req));
|
$response = self::curl_json_post(self::$rpcurl, json_encode($req));
|
||||||
$json = json_decode($response);
|
$json = json_decode($response);
|
||||||
$rpc_block = $json->result;
|
$rpc_block = $json->result;
|
||||||
if (isset($rpc_block->confirmations)) {
|
if (isset($rpc_block->confirmations)) {
|
||||||
|
@ -671,7 +673,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(self::$rpcurl, json_encode($req)));
|
||||||
if (!isset($res->result)) {
|
if (!isset($res->result)) {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
@ -683,7 +685,7 @@ class MainController extends AppController {
|
||||||
private function _gettxoutsetinfo() {
|
private function _gettxoutsetinfo() {
|
||||||
$req = ['method' => 'gettxoutsetinfo', 'params' => []];
|
$req = ['method' => 'gettxoutsetinfo', 'params' => []];
|
||||||
try {
|
try {
|
||||||
$res = json_decode(self::curl_json_post(self::rpcurl, json_encode($req)));
|
$res = json_decode(self::curl_json_post(self::$rpcurl, json_encode($req)));
|
||||||
if (!isset($res->result)) {
|
if (!isset($res->result)) {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
|
@ -4,12 +4,15 @@ namespace App\Shell;
|
||||||
|
|
||||||
use Cake\Console\ConsoleOutput;
|
use Cake\Console\ConsoleOutput;
|
||||||
use Cake\Console\Shell;
|
use Cake\Console\Shell;
|
||||||
|
use Cake\Core\Configure;
|
||||||
use Cake\Datasource\ConnectionManager;
|
use Cake\Datasource\ConnectionManager;
|
||||||
use Cake\Log\Log;
|
use Cake\Log\Log;
|
||||||
use Mdanter\Ecc\EccFactory;
|
use Mdanter\Ecc\EccFactory;
|
||||||
|
|
||||||
class AuxShell extends Shell {
|
class AuxShell extends Shell {
|
||||||
|
|
||||||
|
public static $rpcurl;
|
||||||
|
|
||||||
const bittrex = 'https://bittrex.com/api/v1.1/public/getticker?market=BTC-LBC';
|
const bittrex = 'https://bittrex.com/api/v1.1/public/getticker?market=BTC-LBC';
|
||||||
|
|
||||||
const blockchainticker = 'https://blockchain.info/ticker';
|
const blockchainticker = 'https://blockchain.info/ticker';
|
||||||
|
@ -20,12 +23,11 @@ class AuxShell extends Shell {
|
||||||
|
|
||||||
const scriptAddress = [5, 122];
|
const scriptAddress = [5, 122];
|
||||||
|
|
||||||
const rpcurl = 'http://lrpc:lrpc@127.0.0.1:9245';
|
|
||||||
|
|
||||||
const tagrcptaddress = 'bLockNgmfvnnnZw7bM6SPz6hk5BVzhevEp';
|
const tagrcptaddress = 'bLockNgmfvnnnZw7bM6SPz6hk5BVzhevEp';
|
||||||
|
|
||||||
public function initialize() {
|
public function initialize() {
|
||||||
parent::initialize();
|
parent::initialize();
|
||||||
|
self::$rpcurl = Configure::read('Lbry.RpcUrl');
|
||||||
$this->loadModel('Addresses');
|
$this->loadModel('Addresses');
|
||||||
$this->loadModel('Inputs');
|
$this->loadModel('Inputs');
|
||||||
$this->loadModel('Outputs');
|
$this->loadModel('Outputs');
|
||||||
|
|
|
@ -4,24 +4,26 @@ namespace App\Shell;
|
||||||
|
|
||||||
use Cake\Console\ConsoleOutput;
|
use Cake\Console\ConsoleOutput;
|
||||||
use Cake\Console\Shell;
|
use Cake\Console\Shell;
|
||||||
|
use Cake\Core\Configure;
|
||||||
use Cake\Datasource\ConnectionManager;
|
use Cake\Datasource\ConnectionManager;
|
||||||
use Cake\Log\Log;
|
use Cake\Log\Log;
|
||||||
use Mdanter\Ecc\EccFactory;
|
use Mdanter\Ecc\EccFactory;
|
||||||
|
|
||||||
class BlockShell extends Shell {
|
class BlockShell extends Shell {
|
||||||
|
|
||||||
|
public static $rpcurl;
|
||||||
|
|
||||||
const mempooltxkey = 'lbc.mempooltx';
|
const mempooltxkey = 'lbc.mempooltx';
|
||||||
|
|
||||||
const pubKeyAddress = [0, 85];
|
const pubKeyAddress = [0, 85];
|
||||||
|
|
||||||
const scriptAddress = [5, 122];
|
const scriptAddress = [5, 122];
|
||||||
|
|
||||||
const rpcurl = 'http://lrpc:lrpc@127.0.0.1:9245';
|
|
||||||
|
|
||||||
const redisurl = 'tcp://127.0.0.1:6379';
|
const redisurl = 'tcp://127.0.0.1:6379';
|
||||||
|
|
||||||
public function initialize() {
|
public function initialize() {
|
||||||
parent::initialize();
|
parent::initialize();
|
||||||
|
self::$rpcurl = Configure::read('Lbry.RpcUrl');
|
||||||
$this->loadModel('Blocks');
|
$this->loadModel('Blocks');
|
||||||
$this->loadModel('Addresses');
|
$this->loadModel('Addresses');
|
||||||
$this->loadModel('Claims');
|
$this->loadModel('Claims');
|
||||||
|
@ -42,7 +44,7 @@ class BlockShell extends Shell {
|
||||||
$txid = $otx->TransactionId;
|
$txid = $otx->TransactionId;
|
||||||
$tx = $this->Transactions->find()->select(['Hash'])->where(['Id' => $txid])->first();
|
$tx = $this->Transactions->find()->select(['Hash'])->where(['Id' => $txid])->first();
|
||||||
$req = ['method' => 'getrawtransaction', 'params' => [$tx->Hash]];
|
$req = ['method' => 'getrawtransaction', 'params' => [$tx->Hash]];
|
||||||
$response = self::curl_json_post(self::rpcurl, json_encode($req));
|
$response = self::curl_json_post(self::$rpcurl, json_encode($req));
|
||||||
$json = json_decode($response);
|
$json = json_decode($response);
|
||||||
$tx_result = $json->result;
|
$tx_result = $json->result;
|
||||||
$raw_tx = $tx_result;
|
$raw_tx = $tx_result;
|
||||||
|
@ -160,7 +162,7 @@ class BlockShell extends Shell {
|
||||||
$req = ['method' => 'getvalueforname', 'params' => [$claim_name]];
|
$req = ['method' => 'getvalueforname', 'params' => [$claim_name]];
|
||||||
$json = null;
|
$json = null;
|
||||||
try {
|
try {
|
||||||
$json = json_decode(self::curl_json_post(self::rpcurl, json_encode($req)));
|
$json = json_decode(self::curl_json_post(self::$rpcurl, json_encode($req)));
|
||||||
if (!$json) {
|
if (!$json) {
|
||||||
echo "[$idx_str/$count] getvalueforname failed for [$out->Hash:$vout]. Skipping.\n";
|
echo "[$idx_str/$count] getvalueforname failed for [$out->Hash:$vout]. Skipping.\n";
|
||||||
continue;
|
continue;
|
||||||
|
@ -295,7 +297,7 @@ class BlockShell extends Shell {
|
||||||
$req = ['method' => 'getvalueforname', 'params' => [$claim_name]];
|
$req = ['method' => 'getvalueforname', 'params' => [$claim_name]];
|
||||||
$json = null;
|
$json = null;
|
||||||
try {
|
try {
|
||||||
$json = json_decode(self::curl_json_post(self::rpcurl, json_encode($req)));
|
$json = json_decode(self::curl_json_post(self::$rpcurl, json_encode($req)));
|
||||||
if ($json) {
|
if ($json) {
|
||||||
$claim_data = [];
|
$claim_data = [];
|
||||||
$claim_id = $json->result->claimId;
|
$claim_id = $json->result->claimId;
|
||||||
|
@ -391,7 +393,7 @@ class BlockShell extends Shell {
|
||||||
// getraw
|
// getraw
|
||||||
$req = ['method' => 'getrawtransaction', 'params' => [$tx->Hash]];
|
$req = ['method' => 'getrawtransaction', 'params' => [$tx->Hash]];
|
||||||
$start_ms = round(microtime(true) * 1000);
|
$start_ms = round(microtime(true) * 1000);
|
||||||
$response = self::curl_json_post(self::rpcurl, json_encode($req));
|
$response = self::curl_json_post(self::$rpcurl, json_encode($req));
|
||||||
$diff_ms = (round(microtime(true) * 1000)) - $start_ms;
|
$diff_ms = (round(microtime(true) * 1000)) - $start_ms;
|
||||||
$total_diff += $diff_ms;
|
$total_diff += $diff_ms;
|
||||||
echo "getrawtx took {$diff_ms}ms. ";
|
echo "getrawtx took {$diff_ms}ms. ";
|
||||||
|
@ -673,7 +675,7 @@ class BlockShell extends Shell {
|
||||||
private function processtx($tx_hash, $block_ts, $block_data, &$data_error) {
|
private function processtx($tx_hash, $block_ts, $block_data, &$data_error) {
|
||||||
// Get the raw transaction (Use getrawtx daemon instead (for speed!!!)
|
// Get the raw transaction (Use getrawtx daemon instead (for speed!!!)
|
||||||
$req = ['method' => 'getrawtransaction', 'params' => [$tx_hash]];
|
$req = ['method' => 'getrawtransaction', 'params' => [$tx_hash]];
|
||||||
$response = self::curl_json_post(self::rpcurl, json_encode($req));
|
$response = self::curl_json_post(self::$rpcurl, json_encode($req));
|
||||||
$json = json_decode($response);
|
$json = json_decode($response);
|
||||||
$tx_result = $json->result;
|
$tx_result = $json->result;
|
||||||
$raw_tx = $tx_result;
|
$raw_tx = $tx_result;
|
||||||
|
@ -1075,12 +1077,13 @@ class BlockShell extends Shell {
|
||||||
try {
|
try {
|
||||||
// Get the best block hash
|
// Get the best block hash
|
||||||
$req = ['method' => 'getbestblockhash', 'params' => []];
|
$req = ['method' => 'getbestblockhash', 'params' => []];
|
||||||
$response = self::curl_json_post(self::rpcurl, json_encode($req));
|
$response = self::curl_json_post(self::$rpcurl, json_encode($req));
|
||||||
$json = json_decode($response);
|
$json = json_decode($response);
|
||||||
|
print_r($response); print_r($json);
|
||||||
$best_hash = $json->result;
|
$best_hash = $json->result;
|
||||||
|
|
||||||
$req = ['method' => 'getblock', 'params' => [$best_hash]];
|
$req = ['method' => 'getblock', 'params' => [$best_hash]];
|
||||||
$response = self::curl_json_post(self::rpcurl, json_encode($req));
|
$response = self::curl_json_post(self::$rpcurl, json_encode($req));
|
||||||
$json = json_decode($response);
|
$json = json_decode($response);
|
||||||
$best_block = $json->result;
|
$best_block = $json->result;
|
||||||
|
|
||||||
|
@ -1103,20 +1106,20 @@ class BlockShell extends Shell {
|
||||||
for ($curr_height = $min_height; $curr_height <= $max_height; $curr_height++) {
|
for ($curr_height = $min_height; $curr_height <= $max_height; $curr_height++) {
|
||||||
// get the block hash
|
// get the block hash
|
||||||
$req = ['method' => 'getblockhash', 'params' => [$curr_height]];
|
$req = ['method' => 'getblockhash', 'params' => [$curr_height]];
|
||||||
$response = self::curl_json_post(self::rpcurl, json_encode($req));
|
$response = self::curl_json_post(self::$rpcurl, json_encode($req));
|
||||||
$json = json_decode($response);
|
$json = json_decode($response);
|
||||||
$curr_block_hash = $json->result;
|
$curr_block_hash = $json->result;
|
||||||
|
|
||||||
$next_block_hash = null;
|
$next_block_hash = null;
|
||||||
if ($curr_height < $max_height) {
|
if ($curr_height < $max_height) {
|
||||||
$req = ['method' => 'getblockhash', 'params' => [$curr_height + 1]];
|
$req = ['method' => 'getblockhash', 'params' => [$curr_height + 1]];
|
||||||
$response = self::curl_json_post(self::rpcurl, json_encode($req));
|
$response = self::curl_json_post(self::$rpcurl, json_encode($req));
|
||||||
$json = json_decode($response);
|
$json = json_decode($response);
|
||||||
$next_block_hash = $json->result;
|
$next_block_hash = $json->result;
|
||||||
}
|
}
|
||||||
|
|
||||||
$req = ['method' => 'getblock', 'params' => [$curr_block_hash]];
|
$req = ['method' => 'getblock', 'params' => [$curr_block_hash]];
|
||||||
$response = self::curl_json_post(self::rpcurl, json_encode($req));
|
$response = self::curl_json_post(self::$rpcurl, json_encode($req));
|
||||||
$json = json_decode($response);
|
$json = json_decode($response);
|
||||||
$curr_block = $json->result;
|
$curr_block = $json->result;
|
||||||
|
|
||||||
|
@ -1127,7 +1130,7 @@ class BlockShell extends Shell {
|
||||||
$next_block = null;
|
$next_block = null;
|
||||||
if ($next_block_hash != null) {
|
if ($next_block_hash != null) {
|
||||||
$req = ['method' => 'getblock', 'params' => [$next_block_hash]];
|
$req = ['method' => 'getblock', 'params' => [$next_block_hash]];
|
||||||
$response = self::curl_json_post(self::rpcurl, json_encode($req));
|
$response = self::curl_json_post(self::$rpcurl, json_encode($req));
|
||||||
$json = json_decode($response);
|
$json = json_decode($response);
|
||||||
$next_block = $json->result;
|
$next_block = $json->result;
|
||||||
}
|
}
|
||||||
|
@ -1243,7 +1246,7 @@ class BlockShell extends Shell {
|
||||||
while (true) {
|
while (true) {
|
||||||
try {
|
try {
|
||||||
$data = ['method' => 'getrawmempool', 'params' => []];
|
$data = ['method' => 'getrawmempool', 'params' => []];
|
||||||
$res = self::curl_json_post(self::rpcurl, json_encode($data));
|
$res = self::curl_json_post(self::$rpcurl, json_encode($data));
|
||||||
$json = json_decode($res);
|
$json = json_decode($res);
|
||||||
$txs = $json->result;
|
$txs = $json->result;
|
||||||
$now = new \DateTime('now', new \DateTimeZone('UTC'));
|
$now = new \DateTime('now', new \DateTimeZone('UTC'));
|
||||||
|
|
Loading…
Reference in a new issue