Merge branch 'master' into chainquery
This commit is contained in:
commit
9e984c94c1
5 changed files with 300 additions and 565 deletions
|
@ -6,14 +6,14 @@
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
"require": {
|
"require": {
|
||||||
"php": ">=5.6",
|
"php": ">=5.6",
|
||||||
"cakephp/cakephp": "^3.6",
|
"cakephp/cakephp": "3.4.*",
|
||||||
"mobiledetect/mobiledetectlib": "2.*",
|
"mobiledetect/mobiledetectlib": "2.*",
|
||||||
"cakephp/migrations": "~1.0",
|
"cakephp/migrations": "~1.0",
|
||||||
"cakephp/plugin-installer": "~1.0",
|
"cakephp/plugin-installer": "~1.0",
|
||||||
"mdanter/ecc": "^0.5.0",
|
"mdanter/ecc": "^0.5.0",
|
||||||
"nesbot/carbon": "~1.18",
|
"nesbot/carbon": "~1.18",
|
||||||
"endroid/qrcode": "^2.2.2",
|
"predis/predis": "^1.1.1",
|
||||||
"predis/predis": "^1.1.1"
|
"endroid/qr-code": "^3.5"
|
||||||
},
|
},
|
||||||
"require-dev": {
|
"require-dev": {
|
||||||
"psy/psysh": "@stable",
|
"psy/psysh": "@stable",
|
||||||
|
|
770
composer.lock
generated
770
composer.lock
generated
File diff suppressed because it is too large
Load diff
|
@ -74,7 +74,7 @@ CREATE TABLE `Addresses`
|
||||||
`TotalReceived` DECIMAL(18,8) DEFAULT 0 NOT NULL,
|
`TotalReceived` DECIMAL(18,8) DEFAULT 0 NOT NULL,
|
||||||
`TotalSent` DECIMAL(18,8) DEFAULT 0 NOT NULL,
|
`TotalSent` DECIMAL(18,8) DEFAULT 0 NOT NULL,
|
||||||
`Balance` DECIMAL(18,8) AS (`TotalReceived` - `TotalSent`) PERSISTENT,
|
`Balance` DECIMAL(18,8) AS (`TotalReceived` - `TotalSent`) PERSISTENT,
|
||||||
`Tag` VARCHAR(30) NOT NULL,
|
`Tag` VARCHAR(30),
|
||||||
`TagUrl` VARCHAR(200),
|
`TagUrl` VARCHAR(200),
|
||||||
`Created` DATETIME NOT NULL,
|
`Created` DATETIME NOT NULL,
|
||||||
`Modified` DATETIME NOT NULL,
|
`Modified` DATETIME NOT NULL,
|
||||||
|
|
|
@ -13,6 +13,7 @@ use Cake\Log\Log;
|
||||||
use Endroid\QrCode\ErrorCorrectionLevel;
|
use Endroid\QrCode\ErrorCorrectionLevel;
|
||||||
use Endroid\QrCode\LabelAlignment;
|
use Endroid\QrCode\LabelAlignment;
|
||||||
use Endroid\QrCode\QrCode;
|
use Endroid\QrCode\QrCode;
|
||||||
|
use Endroid\QrCode\Response\QrCodeResponse;
|
||||||
|
|
||||||
|
|
||||||
class MainController extends AppController {
|
class MainController extends AppController {
|
||||||
|
@ -21,6 +22,8 @@ class MainController extends AppController {
|
||||||
|
|
||||||
const lbcPriceKey = 'lbc.price';
|
const lbcPriceKey = 'lbc.price';
|
||||||
|
|
||||||
|
const txOutSetInfo = 'lbrcrd.tosi';
|
||||||
|
|
||||||
const bittrexMarketUrl = 'https://bittrex.com/api/v1.1/public/getticker?market=BTC-LBC';
|
const bittrexMarketUrl = 'https://bittrex.com/api/v1.1/public/getticker?market=BTC-LBC';
|
||||||
|
|
||||||
const blockchainTickerUrl = 'https://blockchain.info/ticker';
|
const blockchainTickerUrl = 'https://blockchain.info/ticker';
|
||||||
|
@ -277,7 +280,7 @@ class MainController extends AppController {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public function blocks($height = null) {
|
public function blocks($height = null) {
|
||||||
$this->loadModel('Blocks');
|
$this->loadModel('Blocks');
|
||||||
$this->loadModel('Outputs');
|
$this->loadModel('Outputs');
|
||||||
|
@ -338,7 +341,7 @@ class MainController extends AppController {
|
||||||
$this->loadModel('Outputs');
|
$this->loadModel('Outputs');
|
||||||
$this->loadModel('Addresses');
|
$this->loadModel('Addresses');
|
||||||
$this->loadModel('Claims');
|
$this->loadModel('Claims');
|
||||||
|
|
||||||
$sourceAddress = $this->request->query('address');
|
$sourceAddress = $this->request->query('address');
|
||||||
|
|
||||||
$tx = $this->Transactions->find()->where(['Transactions.hash' => $hash])->first();
|
$tx = $this->Transactions->find()->where(['Transactions.hash' => $hash])->first();
|
||||||
|
@ -403,7 +406,7 @@ class MainController extends AppController {
|
||||||
$priceRate = $priceInfo->price;
|
$priceRate = $priceInfo->price;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
$lbryAddresses = ['rFLUohPG4tP3gZHYoyhvADCtrDMiaYb7Qd', 'r9PGXsejVJb9ZfMf3QVdDEJCzxkd9JLxzL', 'r9srwX7DEN7Mex3a8oR1mKSqQmLBizoJvi', 'bRo4FEeqqxY7nWFANsZsuKEWByEgkvz8Qt', 'bU2XUzckfpdEuQNemKvhPT1gexQ3GG3SC2', 'bay3VA6YTQBL4WLobbG7CthmoGeUKXuXkD', 'bLPbiXBp6Vr3NSnsHzDsLNzoy5o36re9Cz', 'bMvUBo1h5WS46ThHtmfmXftz3z33VHL7wc', 'bVUrbCK8hcZ5XWti7b9eNxKEBxzc1rr393', 'bZja2VyhAC84a9hMwT8dwTU6rDRXowrjxH', 'bMvUBo1h5WS46ThHtmfmXftz3z33VHL7wc', 'bMgqQqYfwzWWYBk5o5dBMXtCndVAoeqy6h', 'bMvUBo1h5WS46ThHtmfmXftz3z33VHL7wc'];
|
$lbryAddresses = ['rFLUohPG4tP3gZHYoyhvADCtrDMiaYb7Qd', 'r9PGXsejVJb9ZfMf3QVdDEJCzxkd9JLxzL', 'r9srwX7DEN7Mex3a8oR1mKSqQmLBizoJvi', 'bRo4FEeqqxY7nWFANsZsuKEWByEgkvz8Qt', 'bU2XUzckfpdEuQNemKvhPT1gexQ3GG3SC2', 'bay3VA6YTQBL4WLobbG7CthmoGeUKXuXkD', 'bLPbiXBp6Vr3NSnsHzDsLNzoy5o36re9Cz', 'bMvUBo1h5WS46ThHtmfmXftz3z33VHL7wc', 'bVUrbCK8hcZ5XWti7b9eNxKEBxzc1rr393', 'bZja2VyhAC84a9hMwT8dwTU6rDRXowrjxH', 'bMvUBo1h5WS46ThHtmfmXftz3z33VHL7wc', 'bMgqQqYfwzWWYBk5o5dBMXtCndVAoeqy6h', 'bMvUBo1h5WS46ThHtmfmXftz3z33VHL7wc'];
|
||||||
$totalBalance = 0;
|
$totalBalance = 0;
|
||||||
$maxBalance = 0;
|
$maxBalance = 0;
|
||||||
|
@ -451,13 +454,6 @@ class MainController extends AppController {
|
||||||
$recentTxs = [];
|
$recentTxs = [];
|
||||||
|
|
||||||
$tagRequestAmount = 0;
|
$tagRequestAmount = 0;
|
||||||
// Check for pending tag request
|
|
||||||
//$this->loadModel('TagAddressRequests');
|
|
||||||
//$pending = $this->TagAddressRequests->find()->where(['Address' => $addr, 'IsVerified <>' => 1])->first();
|
|
||||||
//if (!$pending) {
|
|
||||||
// $tagRequestAmount = '25.' . rand(11111111, 99999999);
|
|
||||||
//}
|
|
||||||
|
|
||||||
$address = $this->Addresses->find()->where(['address' => $addr])->first();
|
$address = $this->Addresses->find()->where(['address' => $addr])->first();
|
||||||
if (!$address) {
|
if (!$address) {
|
||||||
if (strlen($addr) === 34) {
|
if (strlen($addr) === 34) {
|
||||||
|
@ -512,7 +508,6 @@ class MainController extends AppController {
|
||||||
|
|
||||||
$this->set('offset', $offset);
|
$this->set('offset', $offset);
|
||||||
$this->set('canTag', $canTag);
|
$this->set('canTag', $canTag);
|
||||||
$this->set('tagRequestAmount', $tagRequestAmount);
|
|
||||||
$this->set('address', $address);
|
$this->set('address', $address);
|
||||||
$this->set('totalReceived', $totalRecvAmount);
|
$this->set('totalReceived', $totalRecvAmount);
|
||||||
$this->set('totalSent', $totalSentAmount);
|
$this->set('totalSent', $totalSentAmount);
|
||||||
|
@ -535,15 +530,15 @@ class MainController extends AppController {
|
||||||
$qrCode->setSize(300);
|
$qrCode->setSize(300);
|
||||||
|
|
||||||
// Set advanced options
|
// Set advanced options
|
||||||
$qrCode
|
$qrCode->setWriterByName('png');
|
||||||
->setWriterByName('png')
|
$qrCode->setMargin(10);
|
||||||
->setMargin(10)
|
$qrCode->setEncoding('UTF-8');
|
||||||
->setEncoding('UTF-8')
|
$qrCode->setErrorCorrectionLevel(new ErrorCorrectionLevel(ErrorCorrectionLevel::LOW));
|
||||||
->setErrorCorrectionLevel(ErrorCorrectionLevel::LOW)
|
$qrCode->setForegroundColor(['r' => 0, 'g' => 0, 'b' => 0, 'a' => 0]);
|
||||||
->setForegroundColor(['r' => 0, 'g' => 0, 'b' => 0])
|
$qrCode->setBackgroundColor(['r' => 255, 'g' => 255, 'b' => 255, 'a' => 0]);
|
||||||
->setBackgroundColor(['r' => 255, 'g' => 255, 'b' => 255])
|
$qrCode->setLogoWidth(150);
|
||||||
->setLogoWidth(150)
|
$qrCode->setValidateResult(false);
|
||||||
->setValidateResult(false);
|
|
||||||
|
|
||||||
header('Content-Type: '.$qrCode->getContentType());
|
header('Content-Type: '.$qrCode->getContentType());
|
||||||
echo $qrCode->writeString();
|
echo $qrCode->writeString();
|
||||||
|
@ -613,7 +608,7 @@ class MainController extends AppController {
|
||||||
|
|
||||||
$this->_jsonResponse(['success' => true, 'blocks' => $blocks]);
|
$this->_jsonResponse(['success' => true, 'blocks' => $blocks]);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function apirealtimetx() {
|
public function apirealtimetx() {
|
||||||
// Load 10 transactions
|
// Load 10 transactions
|
||||||
$this->autoRender = false;
|
$this->autoRender = false;
|
||||||
|
@ -622,6 +617,49 @@ class MainController extends AppController {
|
||||||
|
|
||||||
$this->_jsonResponse(['success' => true, 'txs' => $txs]);
|
$this->_jsonResponse(['success' => true, 'txs' => $txs]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
protected function _gettxoutsetinfo() {
|
||||||
|
$now = new \DateTime('now', new \DateTimeZone('UTC'));
|
||||||
|
$txOutSetInfo = new \stdClass();
|
||||||
|
$txOutSetInfo->time = $now->format('c');
|
||||||
|
|
||||||
|
$shouldRefreshSet = false;
|
||||||
|
if (!$this->redis) {
|
||||||
|
$shouldRefreshSet = true;
|
||||||
|
} else {
|
||||||
|
if (!$this->redis->exists(self::txOutSetInfo)) {
|
||||||
|
$shouldRefreshSet = true;
|
||||||
|
} else {
|
||||||
|
$txOutSetInfo = json_decode($this->redis->get(self::txOutSetInfo));
|
||||||
|
$lastTOSIDt = new \DateTime($txOutSetInfo->time);
|
||||||
|
$diff = $now->diff($lastTOSIDt);
|
||||||
|
$diffMinutes = $diff->i;
|
||||||
|
if ($diffMinutes >= 15 || $txOutSetInfo->set == 'N/A') {
|
||||||
|
$shouldRefreshSet = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($shouldRefreshSet) {
|
||||||
|
|
||||||
|
$req = ['method' => 'gettxoutsetinfo', 'params' => []];
|
||||||
|
try {
|
||||||
|
$res = json_decode(self::curl_json_post(self::$rpcurl, json_encode($req)));
|
||||||
|
if (!isset($res->result)) {
|
||||||
|
$txOutSetInfo->tosi = 'N/A';
|
||||||
|
}
|
||||||
|
$txOutSetInfo->tosi = $res->result;
|
||||||
|
} catch (\Exception $e) {
|
||||||
|
$txOutSetInfo->tosi = 'N/A';
|
||||||
|
}
|
||||||
|
$txOutSetInfo->time = $now->format('c');
|
||||||
|
if ($this->redis) {
|
||||||
|
$this->redis->set(self::txOutSetInfo, json_encode($txOutSetInfo));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return (isset($txOutSetInfo->tosi)) ? $txOutSetInfo->tosi : 'N/A';
|
||||||
|
}
|
||||||
|
|
||||||
public function apistatus() {
|
public function apistatus() {
|
||||||
$this->autoRender = false;
|
$this->autoRender = false;
|
||||||
|
@ -900,6 +938,4 @@ class MainController extends AppController {
|
||||||
// Close any open file handle
|
// Close any open file handle
|
||||||
return $response;
|
return $response;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
?>
|
|
|
@ -85,7 +85,6 @@ function buildChartData(blockData) {
|
||||||
inflationRate = ((supply - lastYearSupply) / lastYearSupply) * 100;
|
inflationRate = ((supply - lastYearSupply) / lastYearSupply) * 100;
|
||||||
if(i % skip == 0) { // Only push 1/<skip> of all blocks to optimize data loading
|
if(i % skip == 0) { // Only push 1/<skip> of all blocks to optimize data loading
|
||||||
chartData.push({
|
chartData.push({
|
||||||
date: new Date(blockTime * 1000),
|
|
||||||
date: new Date(blockTime * 1000),
|
date: new Date(blockTime * 1000),
|
||||||
AvailableSupply: supply,
|
AvailableSupply: supply,
|
||||||
RewardLBC: reward,
|
RewardLBC: reward,
|
||||||
|
@ -99,7 +98,7 @@ function buildChartData(blockData) {
|
||||||
|
|
||||||
function loadChartData() {
|
function loadChartData() {
|
||||||
var api_url = "https://chainquery.lbry.io/api/sql?query=";
|
var api_url = "https://chainquery.lbry.io/api/sql?query=";
|
||||||
var query = "SELECT id, block_time FROM block";
|
var query = "SELECT height, block_time FROM block WHERE confirmations > 0 ORDER BY height";
|
||||||
var url = api_url + query;
|
var url = api_url + query;
|
||||||
var loadProgress = $('.mining-inflation-chart-container .load-progress');
|
var loadProgress = $('.mining-inflation-chart-container .load-progress');
|
||||||
$.ajax({
|
$.ajax({
|
||||||
|
|
Loading…
Reference in a new issue