This commit is contained in:
SuriyaR 2019-08-02 18:24:58 +05:30
parent cfa2a7f0bf
commit 6652ee583b
4 changed files with 78 additions and 63 deletions

View File

@ -16,7 +16,7 @@ import {
TransactionFeeDto, TransactionFeeDto,
} from '../dtos'; } from '../dtos';
import { Paginate } from '../utils'; import { Paginate } from '../utils';
const https = require('https'); const http = require('http');
var moment = require('moment'); var moment = require('moment');
@ -374,11 +374,11 @@ export class BlockchainKernelController {
}); });
BlockchainKernelFetchQuery BlockchainKernelFetchQuery
? response.status(200).json({ ? response.status(200).json({
status: 200, status: 200,
timestamp: Date.now(), timestamp: Date.now(),
message: 'blockchain_kernelsuccessfully fetched for given id.', message: 'blockchain_kernelsuccessfully fetched for given id.',
response: { ...BlockchainKernelFetchQuery }, response: { ...BlockchainKernelFetchQuery },
}) })
: next(new NoDataFoundException()); : next(new NoDataFoundException());
} catch (error) { } catch (error) {
next(new InternalServerErrorException(error)); next(new InternalServerErrorException(error));
@ -418,11 +418,11 @@ export class BlockchainKernelController {
).delete(request.params.Id); ).delete(request.params.Id);
BlockchainKernelDeleteQuery BlockchainKernelDeleteQuery
? response.status(200).json({ ? response.status(200).json({
status: 200, status: 200,
timestamp: Date.now(), timestamp: Date.now(),
message: 'blockchain_kernel successfully deleted for given id.', message: 'blockchain_kernel successfully deleted for given id.',
response: { ...BlockchainKernelDeleteQuery }, response: { ...BlockchainKernelDeleteQuery },
}) })
: next(new NoDataFoundException()); : next(new NoDataFoundException());
} catch (error) { } catch (error) {
next(new InternalServerErrorException(error)); next(new InternalServerErrorException(error));
@ -472,7 +472,7 @@ export class BlockchainKernelController {
next(new InternalServerErrorException(error)); next(new InternalServerErrorException(error));
} }
}; };
private Translator = async ( private Translator = async (
request: Request, request: Request,
@ -481,20 +481,20 @@ export class BlockchainKernelController {
) => { ) => {
try { try {
const lang = request.query.lang; const lang = request.query.lang;
/* response.status(200).json({ /* response.status(200).json({
status: 200, status: 200,
timestamp: Date.now(), timestamp: Date.now(),
message: 'Transaction fee chart fetched successfully', message: 'Transaction fee chart fetched successfully',
response: { response: {
lang: lang lang: lang
}, },
}); */ }); */
console.log(path.resolve(__dirname + '/../i18n/'+request.query.lang+'.json')); console.log(path.resolve(__dirname + '/../i18n/' + request.query.lang + '.json'));
console.log("Without :",path.resolve('/../i18n/'+request.query.lang+'.json')); console.log("Without :", path.resolve('/../i18n/' + request.query.lang + '.json'));
response.header("Content-Type",'application/json'); response.header("Content-Type", 'application/json');
response.sendFile(path.resolve(__dirname + '/../i18n/'+request.query.lang+'.json')); response.sendFile(path.resolve(__dirname + '/../i18n/' + request.query.lang + '.json'));
} catch (error) { } catch (error) {
next(new InternalServerErrorException(error)); next(new InternalServerErrorException(error));
} }
@ -506,14 +506,29 @@ export class BlockchainKernelController {
next: NextFunction, next: NextFunction,
) => { ) => {
try { try {
https.get('http://5.9.174.122:3413/v1/peers/connected', (resp) => { http.get('http://5.9.174.122:3413/v1/peers/connected', (resp) => {
console.log('resp resp respresp',resp); // console.log('resp resp respresp',resp);
let data = ''; let data = '';
// A chunk of data has been recieved. // A chunk of data has been recieved.
resp.on('data', function (chunk) {
}); data += chunk;
let dataJson = JSON.parse(data);
dataJson.forEach(function (value, i) {
value['id'] = i;
});
response.status(200).json({
status: 200,
timestamp: Date.now(),
message: 'Peers list fetched successfully',
response: {
dataJson
},
});
});
});
} catch (error) { } catch (error) {
console.log('error 3###########', error);
next(new InternalServerErrorException(error)); next(new InternalServerErrorException(error));
} }
}; };
@ -550,8 +565,8 @@ export class BlockchainKernelController {
.query( .query(
"select 1 as hash, date(DATE_TRUNC('day', timestamp)) as date, sum(fee)/1000000 as fee \ "select 1 as hash, date(DATE_TRUNC('day', timestamp)) as date, sum(fee)/1000000 as fee \
from blockchain_block t1 join blockchain_kernel t2 on t2.block_id=t1.hash where " + from blockchain_block t1 join blockchain_kernel t2 on t2.block_id=t1.hash where " +
timeIntervalQry + timeIntervalQry +
"group by DATE_TRUNC('day', timestamp) order by date", "group by DATE_TRUNC('day', timestamp) order by date",
) )
.catch(err_msg => { .catch(err_msg => {
next(err_msg); next(err_msg);
@ -608,10 +623,10 @@ export class BlockchainKernelController {
.query( .query(
"with hours as ( \ "with hours as ( \
SELECT generate_series('" + SELECT generate_series('" +
fromdate + fromdate +
" 00:00:00'::timestamp, '" + " 00:00:00'::timestamp, '" +
todate + todate +
" 23:00:00', '1 hours') as hour ) select hours.hour, t1.totalinput, t1.totalkernal, t1.totaloutput \ " 23:00:00', '1 hours') as hour ) select hours.hour, t1.totalinput, t1.totalkernal, t1.totaloutput \
from hours left join(select to_char(x.timestamp,'YYYY-MM-DD HH24:00:00') as hour_of_day ,\ from hours left join(select to_char(x.timestamp,'YYYY-MM-DD HH24:00:00') as hour_of_day ,\
SUM(x.input_count) as totalinput, SUM(x.kernal_count) as totalkernal, SUM(x.output_count) as totaloutput\ SUM(x.input_count) as totalinput, SUM(x.kernal_count) as totalkernal, SUM(x.output_count) as totaloutput\
from ( SELECT blockchain_block.hash, \ from ( SELECT blockchain_block.hash, \
@ -629,11 +644,11 @@ LEFT JOIN (select block_id, count(block_id) as block_id_count from blockchain_ke
LEFT JOIN (select block_id, count(block_id) as block_id_count from blockchain_output group by block_id) as bo \ LEFT JOIN (select block_id, count(block_id) as block_id_count from blockchain_output group by block_id) as bo \
ON blockchain_block.hash = \ ON blockchain_block.hash = \
bo.block_id WHERE blockchain_block.timestamp >= '" + bo.block_id WHERE blockchain_block.timestamp >= '" +
fromdate + fromdate +
" 00:00:00' \ " 00:00:00' \
AND blockchain_block.timestamp <= '" + AND blockchain_block.timestamp <= '" +
todate + todate +
" 23:59:59' \ " 23:59:59' \
GROUP BY blockchain_block.hash \ GROUP BY blockchain_block.hash \
ORDER BY blockchain_block.timestamp DESC ) as x \ ORDER BY blockchain_block.timestamp DESC ) as x \
group by to_char(x.timestamp,'YYYY-MM-DD HH24:00:00') \ group by to_char(x.timestamp,'YYYY-MM-DD HH24:00:00') \
@ -745,8 +760,8 @@ LEFT JOIN (select block_id, count(block_id) as block_id_count from blockchain_ou
const TransactionHeatmapChartQuery = await getConnection() const TransactionHeatmapChartQuery = await getConnection()
.query( .query(
'with hours as ( SELECT hour::date from generate_series(' + 'with hours as ( SELECT hour::date from generate_series(' +
seriesquery + seriesquery +
", '1 day') as hour) select hours.hour, \ ", '1 day') as hour) select hours.hour, \
t1.totalinput, \ t1.totalinput, \
t1.totalkernal, \ t1.totalkernal, \
t1.totaloutput \ t1.totaloutput \
@ -767,8 +782,8 @@ LEFT JOIN (select block_id, count(block_id) as block_id_count from blockchain_ke
LEFT JOIN (select block_id, count(block_id) as block_id_count from blockchain_output group by block_id) as bo \ LEFT JOIN (select block_id, count(block_id) as block_id_count from blockchain_output group by block_id) as bo \
ON blockchain_block.hash = \ ON blockchain_block.hash = \
bo.block_id WHERE " + bo.block_id WHERE " +
timeIntervalQry + timeIntervalQry +
" \ " \
GROUP BY blockchain_block.hash \ GROUP BY blockchain_block.hash \
ORDER BY blockchain_block.timestamp DESC) as x \ ORDER BY blockchain_block.timestamp DESC) as x \
group by to_char(x.timestamp,'YYYY-MM-DD') \ group by to_char(x.timestamp,'YYYY-MM-DD') \

View File

@ -272,9 +272,9 @@
</div> </div>
</div> </div>
<div class="col-6 col-md-3 tble_col"> <div class="col-6 col-md-3 tble_col">
<div class="block_div"> <div class="block_div" title="Cuckaroo : {{ peer.total_difficulty.cuckaroo | number }}, Cuckatoo : {{ peer.total_difficulty.cuckatoo | number }}, Progpow : {{ peer.total_difficulty.progpow | number }}, Randomx : {{ peer.total_difficulty.randomx | number }}">
<h6>Total Difficulty</h6> <h6>Total Difficulty</h6>
<span class="blck_value">{{ peer.total_difficulty.cuckaroo }},{{ peer.total_difficulty.cuckatoo}},{{ peer.total_difficulty.randomx}},{{ peer.total_difficulty.progpow}}</span> <span class="blck_value peers_diff">{{ peer.total_difficulty.cuckaroo }},{{ peer.total_difficulty.cuckatoo}},{{ peer.total_difficulty.progpow}},{{ peer.total_difficulty.randomx}}</span>
</div> </div>
</div> </div>
</div> </div>

View File

@ -47,21 +47,15 @@ export class LatestblocksComponent implements OnInit {
} }
public getpeersList() { public getpeersList() {
const httpOptions = { this.chartService.apiGetRequest('','/blockchain_kernel/getpeers').subscribe(
headers: new HttpHeaders({ res => {
'Access-Control-Allow-Origin':'*' if (res['status'] == 200) {
}) this.peers = res.response.dataJson;
}; }
},
this.http error => {},
.get('http://5.9.174.122:3413/v1/peers/connected',httpOptions) );
.subscribe((res) => { // this.peers = [{"id": 1,"capabilities":{"bits":15},"user_agent":"MW/Epic 1.0.0","version":1,"addr":"54.233.177.64:3414","direction":"Outbound","total_difficulty":{"cuckaroo":1630,"cuckatoo":706,"randomx":138024,"progpow":49792},"height":10},{"id": 2,"capabilities":{"bits":15},"user_agent":"MW/Epic 1.0.0","version":1,"addr":"95.216.102.217:3414","direction":"Outbound","total_difficulty":{"cuckaroo":1630,"cuckatoo":706,"randomx":138024,"progpow":49792},"height":10},{"id": 3,"capabilities":{"bits":15},"user_agent":"MW/Epic 1.0.0","version":1,"addr":"90.190.172.177:3414","direction":"Outbound","total_difficulty":{"cuckaroo":2,"cuckatoo":2,"randomx":1024,"progpow":256},"height":0},{"id": 4,"capabilities":{"bits":15},"user_agent":"MW/Epic 1.0.0","version":1,"addr":"67.189.82.196:3414","direction":"Outbound","total_difficulty":{"cuckaroo":1630,"cuckatoo":706,"randomx":138024,"progpow":49792},"height":10},{"id": 5,"capabilities":{"bits":15},"user_agent":"MW/Epic 1.0.0","version":1,"addr":"167.71.72.2:3414","direction":"Outbound","total_difficulty":{"cuckaroo":1630,"cuckatoo":706,"randomx":138024,"progpow":49792},"height":10}];
console.log('reeeee',res);
// this.peers = res;
console.log('this.peers',this.peers);
});
this.peers = [{"id": 1,"capabilities":{"bits":15},"user_agent":"MW/Epic 1.0.0","version":1,"addr":"54.233.177.64:3414","direction":"Outbound","total_difficulty":{"cuckaroo":1630,"cuckatoo":706,"randomx":138024,"progpow":49792},"height":10},{"id": 2,"capabilities":{"bits":15},"user_agent":"MW/Epic 1.0.0","version":1,"addr":"95.216.102.217:3414","direction":"Outbound","total_difficulty":{"cuckaroo":1630,"cuckatoo":706,"randomx":138024,"progpow":49792},"height":10},{"id": 3,"capabilities":{"bits":15},"user_agent":"MW/Epic 1.0.0","version":1,"addr":"90.190.172.177:3414","direction":"Outbound","total_difficulty":{"cuckaroo":2,"cuckatoo":2,"randomx":1024,"progpow":256},"height":0},{"id": 4,"capabilities":{"bits":15},"user_agent":"MW/Epic 1.0.0","version":1,"addr":"67.189.82.196:3414","direction":"Outbound","total_difficulty":{"cuckaroo":1630,"cuckatoo":706,"randomx":138024,"progpow":49792},"height":10},{"id": 5,"capabilities":{"bits":15},"user_agent":"MW/Epic 1.0.0","version":1,"addr":"167.71.72.2:3414","direction":"Outbound","total_difficulty":{"cuckaroo":1630,"cuckatoo":706,"randomx":138024,"progpow":49792},"height":10}];
} }

View File

@ -631,4 +631,10 @@ margin-right: 10px;
.net_dropdwn{ .net_dropdwn{
min-width: 5rem; min-width: 5rem;
padding: 0; padding: 0;
}
.peers_diff{
width: 160px;
overflow: hidden;
display: inline-block;
text-overflow: ellipsis;
} }