Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
72d322ba80 | ||
|
|
5db8e1c9ec | ||
|
|
f42cf56b0c | ||
|
|
b710d7fa7d | ||
|
|
6c9bfbc48b | ||
|
|
5ebe52909e | ||
|
|
e499a3c824 | ||
|
|
02551e98d7 | ||
|
|
007cf0d34c | ||
|
|
c18431394c | ||
|
|
04cbdbcaee | ||
|
|
9b3a1f4097 |
No files matched your search
+22
-18
@@ -1,29 +1,33 @@
|
||||
os: linux
|
||||
dist: xenial
|
||||
language: php
|
||||
|
||||
dist: trusty
|
||||
services:
|
||||
- docker
|
||||
|
||||
sudo: false
|
||||
cache:
|
||||
directories:
|
||||
- $HOME/.composer/cache/files
|
||||
|
||||
php:
|
||||
- 7.0
|
||||
- 7.1
|
||||
|
||||
matrix:
|
||||
fast_finish: true
|
||||
|
||||
include:
|
||||
- php: 7.0
|
||||
env: PHPCS=1
|
||||
env:
|
||||
- DATABASE_URL=mysql://lbry:lbry@localhost:15500/chainquery
|
||||
- DATABASE_TEST_URL=mysql://lbry:lbry@localhost:15500/chainquery
|
||||
|
||||
before_script:
|
||||
- if [[ $PHPCS = 1 ]]; then composer require cakephp/cakephp-codesniffer:~2.1; fi
|
||||
- if [[ $PHPCS != 1 ]]; then composer install; fi
|
||||
- if [[ $PHPCS != 1 ]]; then composer require phpunit/phpunit:"^5.7|^6.0"; fi
|
||||
- if [[ $PHPCS != 1 ]]; then composer run-script post-install-cmd --no-interaction; fi
|
||||
- composer require cakephp/cakephp-codesniffer:~2.1
|
||||
- composer install
|
||||
- composer require phpunit/phpunit:"^5.7|^6.0"
|
||||
- composer run-script post-install-cmd --no-interaction
|
||||
- echo 'lbrycrdurl="rpc://lbry:lbry@lbrycrd:29245"' > chainqueryconfig.toml
|
||||
- echo 'mysqldsn="lbry:lbry@tcp(mysql:3306)/chainquery"' >> chainqueryconfig.toml
|
||||
- echo 'apimysqldsn="lbry:lbry@tcp(mysql:3306)/chainquery"' >> chainqueryconfig.toml
|
||||
- echo 'blockchainname="lbrycrd_regtest"' >> chainqueryconfig.toml
|
||||
- docker-compose up -d
|
||||
- sleep 5
|
||||
|
||||
script:
|
||||
- if [[ $PHPCS != 1 ]]; then vendor/bin/phpunit; fi
|
||||
- if [[ $PHPCS = 1 ]]; then vendor/bin/phpcs -p --extensions=php --standard=vendor/cakephp/cakephp-codesniffer/CakePHP ./src ./tests ./config ./webroot; fi
|
||||
- DATABASE_TEST_URL=mysql://lbry:lbry@localhost:15500/chainquery vendor/bin/phpunit
|
||||
- vendor/bin/phpcs -p --extensions=php --standard=vendor/cakephp/cakephp-codesniffer/CakePHP ./src ./tests ./config ./webroot
|
||||
|
||||
notifications:
|
||||
email: false
|
||||
@@ -6,7 +6,6 @@ A simple PHP block explorer for browsing transactions and claims on the [LBRY](h
|
||||
There are some prerequisites that need to be installed before the explorer can be accessed.
|
||||
* Web server - Apache, caddy or nginx
|
||||
* [lbrycrd](https://github.com/lbryio/lbrycrd) with txindex turned on
|
||||
* [Python claims decoder](https://github.com/cryptodevorg/lbry-decoder)
|
||||
* MariaDB 10.2 or higher
|
||||
* Redis Server (optional, only required for the CakePHP redis cache engine, or to run `forevermempool`)
|
||||
* PHP 7.2 or higher
|
||||
|
||||
Generated
+627
-450
File diff suppressed because it is too large.
Load diff
@@ -222,8 +222,8 @@ Type::build('timestamp')
|
||||
* Debug Kit should not be installed on a production system
|
||||
*/
|
||||
if (Configure::read('debug')) {
|
||||
//Plugin::load('DebugKit', ['bootstrap' => true]);
|
||||
Application::addPlugin('DebugKit', ['bootstrap' => true]);
|
||||
Plugin::load('DebugKit', ['bootstrap' => true]);
|
||||
//Application::addPlugin('DebugKit', ['bootstrap' => true]);
|
||||
}
|
||||
|
||||
Configure::load('lbry','lbry.default');
|
||||
|
||||
@@ -0,0 +1,47 @@
|
||||
version: "3.5"
|
||||
services:
|
||||
#############
|
||||
## Lbrycrd ##
|
||||
#############
|
||||
lbrycrd:
|
||||
image: lbry/lbrycrd:v0.17.3.2-deprecatedrpc
|
||||
restart: "no"
|
||||
ports:
|
||||
- "15201:29246"
|
||||
- "15200:29245"
|
||||
expose:
|
||||
- "29246"
|
||||
- "29245"
|
||||
## host volumes for persistent data such as wallet private keys.
|
||||
volumes:
|
||||
- "./persist:/data"
|
||||
environment:
|
||||
- RUN_MODE=regtest
|
||||
###########
|
||||
## MySQL ##
|
||||
###########
|
||||
mysql:
|
||||
image: mysql/mysql-server:5.7.27
|
||||
restart: "no"
|
||||
ports:
|
||||
- "15500:3306"
|
||||
environment:
|
||||
- MYSQL_ALLOW_EMPTY_PASSWORD=true
|
||||
- MYSQL_DATABASE=chainquery
|
||||
- MYSQL_USER=lbry
|
||||
- MYSQL_PASSWORD=lbry
|
||||
- MYSQL_LOG_CONSOLE=true
|
||||
################
|
||||
## Chainquery ##
|
||||
################
|
||||
chainquery:
|
||||
image: lbry/chainquery:v2.0.8
|
||||
restart: "no"
|
||||
ports:
|
||||
- 6300:6300
|
||||
depends_on:
|
||||
- lbrycrd
|
||||
- mysql
|
||||
volumes:
|
||||
- ./chainqueryconfig.toml:/etc/lbry/chainqueryconfig.toml
|
||||
entrypoint: wait-for-it -t 0 lbrycrd:29245 -- wait-for-it -t 0 mysql:3306 -- start
|
||||
@@ -136,6 +136,10 @@ class MainController extends AppController {
|
||||
$count = $stmt->fetch(\PDO::FETCH_OBJ);
|
||||
$numClaims = $count->Total;
|
||||
|
||||
$stmt = $conn->execute('SELECT MAX(id) AS MaxId FROM claim');
|
||||
$res = $stmt->fetch(\PDO::FETCH_OBJ);
|
||||
$maxClaimId = $res->MaxId;
|
||||
|
||||
$numPages = ceil($numClaims / $pageLimit);
|
||||
if ($page < 1) {
|
||||
$page = 1;
|
||||
@@ -144,14 +148,22 @@ class MainController extends AppController {
|
||||
$page = $numPages;
|
||||
}
|
||||
|
||||
$offset = ($page - 1) * $pageLimit;
|
||||
$claims = $this->Claims->find()->select($this->Claims)->select(['publisher' => 'C.name'])->leftJoin(['C' => 'claim'], ['C.claim_id = Claims.publisher_id'])->order(['Claims.created_at' => 'DESC'])->offset($offset)->limit($pageLimit)->toArray();
|
||||
$startLimitId = $maxClaimId - ($page * $pageLimit);
|
||||
$endLimitId = $startLimitId + $pageLimit;
|
||||
if ($endLimitId > $maxClaimId) {
|
||||
$endLimitId = $maxClaimId;
|
||||
}
|
||||
|
||||
$claims = $this->Claims->find()->select($this->Claims)->
|
||||
select(['publisher' => 'C.name'])->leftJoin(['C' => 'claim'], ['C.claim_id = Claims.publisher_id'])->
|
||||
where(['Claims.id >' => $startLimitId, 'Claims.id <=' => $endLimitId])->
|
||||
order(['Claims.id' => 'DESC'])->toArray();
|
||||
|
||||
for ($i = 0; $i < count($claims); $i++) {
|
||||
if ($canConvert && $claims[$i]->fee > 0 && $claims[$i]->fee_currency == 'USD') {
|
||||
$claims[$i]->price = $claims[$i]->fee / $priceInfo->price;
|
||||
}
|
||||
|
||||
|
||||
if (isset($claims[$i]->Stream)) {
|
||||
$json = json_decode($claims[$i]->Stream->Stream);
|
||||
if (isset($json->metadata->license)) {
|
||||
@@ -226,7 +238,7 @@ class MainController extends AppController {
|
||||
}
|
||||
|
||||
$transactions = $this->Transactions->find()->select(['Transactions.id', 'Transactions.hash', 'Transactions.value', 'Transactions.input_count', 'Transactions.output_count', 'Transactions.transaction_time', 'Transactions.created_at'])->order(['Transactions.created_at' => 'desc'])->limit(10)->toArray();
|
||||
|
||||
|
||||
$this->set('blocks', $blocks);
|
||||
$this->set('txs', $transactions);
|
||||
}
|
||||
@@ -359,21 +371,21 @@ class MainController extends AppController {
|
||||
else {
|
||||
$last_block = $this->Blocks->find()->select(['height'])->order(['height' => 'desc'])->first();
|
||||
$confirmations = $last_block->height - $block->height + 1;
|
||||
}
|
||||
}
|
||||
$inputs = $this->Inputs->find()->where(['transaction_id' => $tx->id])->order(['prevout_n' => 'asc'])->toArray();
|
||||
foreach($inputs as $input) {
|
||||
$inputAddresses = $this->Addresses->find()->select(['id', 'address'])->where(['id' => $input->input_address_id])->toArray();
|
||||
$input->input_addresses = $inputAddresses;
|
||||
}
|
||||
|
||||
|
||||
$outputs = $this->Outputs->find()->select($this->Outputs)->select(['spend_input_hash' => 'I.transaction_hash', 'spend_input_id' => 'I.id'])->where(['Outputs.transaction_id' => $tx->id])->leftJoin(['I' => 'input'], ['I.id = Outputs.spent_by_input_id'])->order(['Outputs.vout' => 'asc'])->toArray();
|
||||
for ($i = 0; $i < count($outputs); $i++) {
|
||||
for ($i = 0; $i < count($outputs); $i++) {
|
||||
$outputs[$i]->IsClaim = (strpos($outputs[$i]->script_pub_key_asm, 'CLAIM') > -1);
|
||||
$outputs[$i]->IsSupportClaim = (strpos($outputs[$i]->script_pub_key_asm, 'SUPPORT_CLAIM') > -1);
|
||||
$outputs[$i]->IsUpdateClaim = (strpos($outputs[$i]->script_pub_key_asm, 'UPDATE_CLAIM') > -1);
|
||||
$claim = $this->Claims->find()->select(['id', 'claim_id', 'claim_address', 'vout', 'transaction_hash_id'])->where(['transaction_hash_id' => $tx->hash, 'vout' => $outputs[$i]->vout])->first();
|
||||
$outputs[$i]->Claim = $claim;
|
||||
|
||||
|
||||
$output_address = trim($outputs[$i]->address_list, '[""]');
|
||||
if(!$output_address && $claim) {
|
||||
$output_address = $claim->claim_address;
|
||||
@@ -477,7 +489,7 @@ class MainController extends AppController {
|
||||
$canTag = true;
|
||||
$transactionAddresses = $this->TransactionAddresses->find()->where(['address_id' => $address->id])->toArray();
|
||||
$numTransactions = count($transactionAddresses);
|
||||
|
||||
|
||||
$all = $this->request->query('all');
|
||||
if ($all === 'true') {
|
||||
$offset = 0;
|
||||
@@ -495,7 +507,7 @@ class MainController extends AppController {
|
||||
|
||||
$offset = ($page - 1) * $pageLimit;
|
||||
}
|
||||
|
||||
|
||||
$stmt = $conn->execute(sprintf(
|
||||
'SELECT T.id, T.hash, T.input_count, T.output_count, T.block_hash_id, ' .
|
||||
' TA.debit_amount, TA.credit_amount, ' .
|
||||
@@ -552,7 +564,7 @@ class MainController extends AppController {
|
||||
echo $qrCode->writeString();
|
||||
exit(0);
|
||||
}
|
||||
|
||||
|
||||
public function apiblocksize($timePeriod = '24h') {
|
||||
$this->autoRender = false;
|
||||
|
||||
@@ -587,7 +599,7 @@ class MainController extends AppController {
|
||||
$resultSet[$price->TimePeriod]['AvgUSD'] = (float) $price->AvgUSD;
|
||||
}
|
||||
*/
|
||||
|
||||
|
||||
$conn = ConnectionManager::get('default');
|
||||
// get avg block sizes for the time period
|
||||
$stmt = $conn->execute("SELECT AVG(block_size) AS AvgBlockSize, DATE_FORMAT(FROM_UNIXTIME(block_time), '$sqlDateFormat') AS TimePeriod " .
|
||||
@@ -602,7 +614,7 @@ class MainController extends AppController {
|
||||
|
||||
return $this->_jsonResponse(['success' => true, 'data' => $resultSet]);
|
||||
}
|
||||
|
||||
|
||||
public function apirealtimeblocks() {
|
||||
// Load 10 blocks
|
||||
$this->autoRender = false;
|
||||
@@ -616,7 +628,7 @@ class MainController extends AppController {
|
||||
|
||||
$this->_jsonResponse(['success' => true, 'blocks' => $blocks]);
|
||||
}
|
||||
|
||||
|
||||
public function apirealtimetx() {
|
||||
// Load 10 transactions
|
||||
$this->autoRender = false;
|
||||
@@ -625,7 +637,7 @@ class MainController extends AppController {
|
||||
|
||||
$this->_jsonResponse(['success' => true, 'txs' => $txs]);
|
||||
}
|
||||
|
||||
|
||||
protected function _gettxoutsetinfo() {
|
||||
$now = new \DateTime('now', new \DateTimeZone('UTC'));
|
||||
$txOutSetInfo = new \stdClass();
|
||||
@@ -775,12 +787,12 @@ class MainController extends AppController {
|
||||
if (!isset($base58address)) {
|
||||
return $this->_jsonError('Base58 address not specified.', 400);
|
||||
}
|
||||
|
||||
|
||||
$address = $this->Addresses->find()->select(['id', 'balance'])->where(['address' => $base58address])->first();
|
||||
if (!$address) {
|
||||
return $this->_jsonError('Could not find address.', 400);
|
||||
}
|
||||
|
||||
|
||||
return $this->_jsonResponse(['success' => true, ['balance' => ['confirmed' => $address->balance, 'unconfirmed' => 0]]]);
|
||||
}
|
||||
|
||||
@@ -840,20 +852,20 @@ class MainController extends AppController {
|
||||
|
||||
$circulating = 0;
|
||||
$txoutsetinfo = $this->_gettxoutsetinfo();
|
||||
|
||||
|
||||
$reservedcommunity = ['rFLUohPG4tP3gZHYoyhvADCtrDMiaYb7Qd'];
|
||||
$reservedoperational = ['r9PGXsejVJb9ZfMf3QVdDEJCzxkd9JLxzL'];
|
||||
$reservedinstitutional = ['r9srwX7DEN7Mex3a8oR1mKSqQmLBizoJvi'];
|
||||
$reservedaux = ['bRo4FEeqqxY7nWFANsZsuKEWByEgkvz8Qt', 'bU2XUzckfpdEuQNemKvhPT1gexQ3GG3SC2', 'bay3VA6YTQBL4WLobbG7CthmoGeUKXuXkD', 'bLPbiXBp6Vr3NSnsHzDsLNzoy5o36re9Cz', 'bMvUBo1h5WS46ThHtmfmXftz3z33VHL7wc', 'bVUrbCK8hcZ5XWti7b9eNxKEBxzc1rr393', 'bZja2VyhAC84a9hMwT8dwTU6rDRXowrjxH', 'bCrboXVztuSbZzVToCWSsu1pEr2oxKHu9v', 'bMgqQqYfwzWWYBk5o5dBMXtCndVAoeqy6h'];
|
||||
$allAddresses = array_merge($reservedcommunity, $reservedoperational, $reservedinstitutional, $reservedaux);
|
||||
|
||||
|
||||
$reservedtotal = $this->Addresses->find()->select(['id', 'balance' => 'SUM(balance)'])->where(['Addresses.address IN' => $allAddresses])->first();
|
||||
|
||||
$circulating = $txoutsetinfo->total_amount - ($reservedtotal->balance);
|
||||
|
||||
return $this->_jsonResponse(['success' => true, 'utxosupply' => ['total' => $txoutsetinfo->total_amount, 'circulating' => $circulating]]);
|
||||
}
|
||||
|
||||
|
||||
protected function _formatHashRate($value) {
|
||||
if ($value === 'N/A') {
|
||||
return $value;
|
||||
|
||||
Reference in new issue
Block a user