Blocks Mined data changed

This commit is contained in:
vijikannan 2019-07-29 11:31:50 +05:30
parent eddb90cf25
commit 3174184928
3 changed files with 102 additions and 63 deletions

View File

@ -1352,14 +1352,15 @@ export class BlockchainBlockController {
} }
const BlockMineChartQuery = await getConnection() const BlockMineChartQuery = await getConnection()
.query( .query(
"SELECT hash, date , total_edge_bits, cuckARoo29, cuckAToo31, ROUND(cuckARoo29 * 100.0 / total_edge_bits,2) as cuckARoo29per, ROUND(cuckAToo31 * 100.0 / total_edge_bits,2) as cuckAToo31per \ "SELECT hash, date , total_edge_bits, RandomX, Cuckoo, ProgPow, Round(RandomX * 100.0 / total_edge_bits,2) AS RandomXper, Round(Cuckoo * 100.0 / total_edge_bits,2) AS Cuckooper,Round(ProgPow * 100.0 / total_edge_bits,2) AS ProgPowper \
FROM (SELECT 1 as hash, \ FROM (SELECT 1 as hash, \
date(DATE_TRUNC('day', timestamp at time zone '" + date(DATE_TRUNC('day', timestamp at time zone '" +
process.env.TIME_ZONE + process.env.TIME_ZONE +
"')) as date, \ "')) as date, \
COUNT(edge_bits) AS total_edge_bits, \ COUNT(edge_bits) AS total_edge_bits, \
COUNT(CASE WHEN edge_bits = 29 THEN 1 ELSE NULL END) AS cuckARoo29, \ Count( CASE WHEN proof = 'RandomX' THEN 1 ELSE NULL END) AS RandomX, \
COUNT(CASE WHEN edge_bits = 31 THEN 1 ELSE NULL END) AS cuckAToo31 \ Count( CASE WHEN proof = 'Cuckoo' THEN 1 ELSE NULL END) AS Cuckoo,\
Count( CASE WHEN proof = 'ProgPow' THEN 1 ELSE NULL END) AS ProgPow \
FROM blockchain_block \ FROM blockchain_block \
where " + where " +
timeIntervalQry + timeIntervalQry +
@ -1371,32 +1372,39 @@ export class BlockchainBlockController {
next(err_msg); next(err_msg);
}); });
let date = [], let date = [],
cuckARoo29per = [], RandomXper = [],
cuckAToo31per = [], Cuckooper = [],
cuckARoo29Val = [], ProgPowper = [],
cuckAToo31Val = []; RandomX = [],
Cuckoo = [],
ProgPow = [];
BlockMineChartQuery.forEach(e => { BlockMineChartQuery.forEach(e => {
console.log('e', e);
date.push(moment(e.date).format('YYYY-MM-DD')); date.push(moment(e.date).format('YYYY-MM-DD'));
cuckARoo29per.push(parseFloat(e.cuckaroo29per)); RandomXper.push(parseFloat(e.randomxper));
cuckAToo31per.push(parseFloat(e.cuckatoo31per)); Cuckooper.push(parseFloat(e.cuckooper));
cuckARoo29Val.push(parseInt(e.cuckaroo29)); ProgPowper.push(parseFloat(e.progpowper));
cuckAToo31Val.push(parseInt(e.cuckatoo31)); RandomX.push(parseInt(e.randomx));
Cuckoo.push(parseInt(e.cuckoo));
ProgPow.push(parseInt(e.progpow));
}); });
response.status(200).json({ response.status(200).json({
status: 200, status: 200,
timestamp: Date.now(), timestamp: Date.now(),
message: 'period of blocks generation per second fetched Successfully', message: 'period of blocks generation per second fetched Successfully',
response: { response: {
date, date,
cuckARoo29per, RandomXper,
cuckAToo31per, ProgPowper,
cuckARoo29Val, RandomX,
cuckAToo31Val, Cuckoo,
ProgPow,
}, },
}); });
} catch (error) { } catch (error) {
next(new InternalServerErrorException(error)); next(new InternalServerErrorException(error));
} }
}; };
} }

View File

@ -85,6 +85,13 @@ export class BlockchainBlock {
}) })
EdgeBits: number; EdgeBits: number;
@Column('character varying', {
nullable: false,
length: 64,
name: 'proof',
})
Proof: string;
@Column('int4', { @Column('int4', {
nullable: false, nullable: false,
array: true, array: true,

View File

@ -186,17 +186,23 @@ export class GraphListComponent implements OnInit {
res => { res => {
if (res['status'] == 200) { if (res['status'] == 200) {
let mDate = res.response.date; let mDate = res.response.date;
let mcuck29 = res.response.cuckARoo29per; let ProgPow = res.response.ProgPow;
let mcuck31 = res.response.cuckAToo31per; let Cuckoo = res.response.Cuckoo;
let mcuck29val = res.response.cuckARoo29Val; let RandomX = res.response.RandomX;
let mcuck31val = res.response.cuckAToo31Val;
this.dg_last = mcuck29val[mcuck29val.length - 1]; let ProgPowper = res.response.ProgPowper;
let Cuckooper = res.response.Cuckooper;
let RandomXper = res.response.RandomXper;
this.dg_last = RandomXper[RandomXper.length - 1];
this.blockminedFunc( this.blockminedFunc(
mDate, mDate,
mcuck29, ProgPow,
mcuck31, Cuckoo,
mcuck29val, RandomX,
mcuck31val, ProgPowper,
Cuckooper,
RandomXper,
); );
resolve(); resolve();
} }
@ -506,14 +512,14 @@ export class GraphListComponent implements OnInit {
}; };
} }
blockminedFunc(mDate, mcuck29, mcuck31, mcuck29val, mcuck31val) { blockminedFunc(mDate,ProgPow, Cuckoo, RandomX, ProgPowper, Cuckooper, RandomXper) {
this.doubleareaGraphData = { this.doubleareaGraphData = {
data: [ data: [
{ {
x: mDate, x: mDate,
y: mcuck29, y: Cuckooper,
text: mcuck29val, text: Cuckoo,
hovertemplate: 'cuckARoo29 :%{y} % ( %{text:,} )', hovertemplate: 'Cuckoo :%{y} % ( %{text:,} )',
name: '', name: '',
fill: 'tozeroy', fill: 'tozeroy',
type: 'line', type: 'line',
@ -523,9 +529,9 @@ export class GraphListComponent implements OnInit {
}, },
{ {
x: mDate, x: mDate,
y: mcuck31, y: RandomXper,
text: mcuck31val, text: RandomX,
hovertemplate: 'cuckAToo31 :%{y} % ( %{text:,} )', hovertemplate: 'RandomX :%{y} % ( %{text:,} )',
fill: 'tozeroy', fill: 'tozeroy',
type: 'line', type: 'line',
name: '', name: '',
@ -533,6 +539,18 @@ export class GraphListComponent implements OnInit {
color: '#1ad5e9', color: '#1ad5e9',
}, },
}, },
{
x: mDate,
y: ProgPowper,
text: ProgPow,
hovertemplate: 'ProgPow :%{y} % ( %{text:,} )',
fill: 'tozeroy',
type: 'line',
name: '',
line: {
color: '#f74f4f',
},
},
], ],
layout: { layout: {
hovermode: 'closest', hovermode: 'closest',
@ -542,9 +560,15 @@ export class GraphListComponent implements OnInit {
xaxis: { xaxis: {
tickformat: '%m-%d', tickformat: '%m-%d',
tickangle: -45, tickangle: -45,
rangemode: 'nonnegative',
fixedrange: true,
showgrid: true,
}, },
yaxis: { yaxis: {
title: 'Percentage(%)', title: 'Percentage(%)',
rangemode: 'nonnegative',
fixedrange: true,
showgrid: true,
}, },
margin: { margin: {
l: 50, l: 50,