From f2eab024c12939eaf335f10c725affb3d3ac1633 Mon Sep 17 00:00:00 2001 From: "raja.blaze" Date: Mon, 12 Aug 2019 18:20:12 +0530 Subject: [PATCH 01/18] Changes updated --- server/controllers/BlockchainBlock.ts | 103 +++++++++--------- .../home/graph-list/graph-list.component.ts | 2 +- 2 files changed, 51 insertions(+), 54 deletions(-) diff --git a/server/controllers/BlockchainBlock.ts b/server/controllers/BlockchainBlock.ts index f0bb6ce..a902807 100644 --- a/server/controllers/BlockchainBlock.ts +++ b/server/controllers/BlockchainBlock.ts @@ -828,7 +828,7 @@ export class BlockchainBlockController { console.log('error', error); next(new InternalServerErrorException(error)); } - + }; private BlockchainBlockUpdate = async ( @@ -1167,30 +1167,18 @@ export class BlockchainBlockController { var dateFormat = 'YYYY-MM-DD HH:mm:ss'; var tickFormat = '%H-%M'; } - if(Difftype == "target"){ - var TotalDifficultyNBlockQuery = await getConnection() - .query( - "SELECT a.hash, a.tarket_difficulty, a.date FROM(select 1 as hash, (total_difficulty_"+alog_type+" - LAG(total_difficulty_"+alog_type+") OVER (ORDER BY total_difficulty_"+alog_type+")) AS tarket_difficulty, \ - DATE_TRUNC('minute', timestamp at time zone '" + - process.env.TIME_ZONE + - "') as date \ - from blockchain_block where " + - timeIntervalQry + - " order by height) as a WHERE a.tarket_difficulty IS NOT NULL", - ) - .catch(err_msg => { - next(err_msg); - }); - }else if(Difftype == "solution"){ + if(Difftype == "target"){ var TotalDifficultyNBlockQuery = await getConnection() .query( - "SELECT a.hash, a.tarket_difficulty, a.date FROM(select 1 as hash, (total_difficulty_"+alog_type+" - LAG(total_difficulty_"+alog_type+") OVER (ORDER BY total_difficulty_"+alog_type+")) AS tarket_difficulty, \ + "SELECT a.hash, a.total_difficulty_randomx, a.total_difficulty_cuckatoo,a.total_difficulty_progpow, a.date FROM(select 1 as hash, (total_difficulty_cuckatoo - LAG(total_difficulty_cuckatoo) OVER (ORDER BY total_difficulty_cuckatoo)) AS total_difficulty_cuckatoo, \ + (total_difficulty_progpow - LAG(total_difficulty_progpow) OVER (ORDER BY total_difficulty_progpow)) AS total_difficulty_progpow , \ + (total_difficulty_randomx - LAG(total_difficulty_randomx) OVER (ORDER BY total_difficulty_randomx)) AS total_difficulty_randomx, \ DATE_TRUNC('minute', timestamp at time zone '" + process.env.TIME_ZONE + "') as date \ from blockchain_block where " + timeIntervalQry + - " order by height) as a WHERE a.tarket_difficulty IS NOT NULL", + " order by height) as a WHERE a.total_difficulty_randomx IS NOT NULL AND a.total_difficulty_progpow IS NOT NULL AND a.total_difficulty_cuckatoo IS NOT NULL AND a.total_difficulty_cuckatoo != '0' AND a.total_difficulty_randomx != '0' AND a.total_difficulty_progpow != '0'", ) .catch(err_msg => { next(err_msg); @@ -1198,7 +1186,7 @@ export class BlockchainBlockController { }else if(Difftype == "total"){ var TotalDifficultyNBlockQuery = await getConnection() .query( - "select 1 as hash, total_difficulty_"+alog_type+" as tarket_difficulty, \ + "select 1 as hash, total_difficulty_cuckatoo,total_difficulty_progpow,total_difficulty_randomx, \ DATE_TRUNC('minute', timestamp at time zone '" + process.env.TIME_ZONE + "') as date \ @@ -1209,45 +1197,55 @@ export class BlockchainBlockController { .catch(err_msg => { next(err_msg); }); - }else{ - var TotalDifficultyNBlockQuery = await getConnection() - .query( - "SELECT a.hash, a.tarket_difficulty, a.date FROM(select 1 as hash, (total_difficulty_"+alog_type+" - LAG(total_difficulty_"+alog_type+") OVER (ORDER BY total_difficulty_"+alog_type+")) AS tarket_difficulty, \ - DATE_TRUNC('minute', timestamp at time zone '" + - process.env.TIME_ZONE + - "') as date \ - from blockchain_block where " + - timeIntervalQry + - " order by height) as a WHERE a.tarket_difficulty IS NOT NULL", - ) - .catch(err_msg => { - next(err_msg); - }); } let date = [], - //DifficultyCuckaroo = [], - //DifficultyCuckatoo = [], - //DifficultyProgpow = [], - //DifficultyRandomx = []; - - TargetDifficulty = []; + DifficultyCuckatoo = [], + DifficultyProgpow = [], + DifficultyRandomx = []; TotalDifficultyNBlockQuery.forEach(e => { - //date.indexOf(moment(e.date).format('YYYY-MM-DD')) < 0 ? date.push(moment(e.date).format(dateFormat)); - // DifficultyCuckaroo.push(parseInt(e.total_difficulty_cuckaroo)); - // DifficultyCuckatoo.push(parseInt(e.total_difficulty_cuckatoo)); - // DifficultyProgpow.push(parseInt(e.total_difficulty_progpow)); - // DifficultyRandomx.push(parseInt(e.total_difficulty_randomx)); - TargetDifficulty.push(parseInt(e.tarket_difficulty)); + DifficultyCuckatoo.push(parseInt(e.total_difficulty_cuckatoo)); + DifficultyProgpow.push(parseInt(e.total_difficulty_progpow)); + DifficultyRandomx.push(parseInt(e.total_difficulty_randomx)); }); - - var Maxrange = Math.max.apply(Math, TotalDifficultyNBlockQuery.map(function(o) { return o.tarket_difficulty; })); - var Minrange = Math.min.apply(Math, TotalDifficultyNBlockQuery.map(function(o) { return o.tarket_difficulty; })); + var Maxrange; + var Minrange; + if(alog_type == "cuckatoo"){ + Maxrange = Math.max.apply(Math, TotalDifficultyNBlockQuery.map(function(o) { return o.total_difficulty_cuckatoo; })); + Minrange = Math.min.apply(Math, TotalDifficultyNBlockQuery.map(function(o) { return o.total_difficulty_cuckatoo; })); if(Minrange != 0){ - Minrange = (Minrange - (Minrange * 0.2)); + Minrange = (Minrange - (Minrange * 0.2)); } Maxrange = (Maxrange + (Maxrange * 0.2)); + }else if(alog_type == "progpow"){ + Maxrange = Math.max.apply(Math, TotalDifficultyNBlockQuery.map(function(o) { return o.total_difficulty_progpow; })); + Minrange = Math.min.apply(Math, TotalDifficultyNBlockQuery.map(function(o) { return o.total_difficulty_progpow; })); + if(Minrange != 0){ + Minrange = (Minrange - (Minrange * 0.2)); + } + Maxrange = (Maxrange + (Maxrange * 0.2)); + }else if(alog_type == "randomx"){ + Maxrange = Math.max.apply(Math, TotalDifficultyNBlockQuery.map(function(o) { return o.total_difficulty_randomx; })); + Minrange = Math.min.apply(Math, TotalDifficultyNBlockQuery.map(function(o) { return o.total_difficulty_randomx; })); + if(Minrange != 0){ + Minrange = (Minrange - (Minrange * 0.2)); + } + Maxrange = (Maxrange + (Maxrange * 0.2)); + }else{ + var Maxrange1 = Math.max.apply(Math, TotalDifficultyNBlockQuery.map(function(o) { return o.total_difficulty_cuckatoo; })); + var Minrange1 = Math.min.apply(Math, TotalDifficultyNBlockQuery.map(function(o) { return o.total_difficulty_cuckatoo; })); + var Maxrange2 = Math.max.apply(Math, TotalDifficultyNBlockQuery.map(function(o) { return o.total_difficulty_progpow; })); + var Minrange2 = Math.min.apply(Math, TotalDifficultyNBlockQuery.map(function(o) { return o.total_difficulty_progpow; })); + var Maxrange3 = Math.max.apply(Math, TotalDifficultyNBlockQuery.map(function(o) { return o.total_difficulty_randomx; })); + var Minrange3 = Math.min.apply(Math, TotalDifficultyNBlockQuery.map(function(o) { return o.total_difficulty_randomx; })); + Maxrange = Math.max(Maxrange1, Maxrange2, Maxrange3); + Minrange = Math.min(Minrange1, Minrange2, Minrange3); + if(Minrange != 0){ + Minrange = (Minrange - (Minrange * 0.2)); + } + Maxrange = (Maxrange + (Maxrange * 0.2)); + } // Minrange = parseInt(Minrange); // var Minrange2 = parseInt(Minrange * 0.3); @@ -1257,12 +1255,11 @@ export class BlockchainBlockController { message: 'Difficulty and Blocks Data fetched Successfully', response: { Date: date, - // DifficultyCuckaroo: DifficultyCuckaroo, - // DifficultyCuckatoo: DifficultyCuckatoo, - // DifficultyProgpow: DifficultyProgpow, + DifficultyCuckatoo: DifficultyCuckatoo, + DifficultyRandomx: DifficultyRandomx, + DifficultyProgpow: DifficultyProgpow, Maxrange: Maxrange, Minrange: Minrange, - TargetDifficulty: TargetDifficulty, tickFormat: tickFormat }, }); diff --git a/src/app/view/home/graph-list/graph-list.component.ts b/src/app/view/home/graph-list/graph-list.component.ts index 5f3a139..b3db4c8 100644 --- a/src/app/view/home/graph-list/graph-list.component.ts +++ b/src/app/view/home/graph-list/graph-list.component.ts @@ -819,7 +819,7 @@ export class GraphListComponent implements OnInit { showgrid: true, }, yaxis: { - title: 'Blocks / sec', + title: 'Seconds / Block', rangemode: 'nonnegative', fixedrange: true, showgrid: true, From 7b7a0108aadc6a668406dbcc30f31724a31b3d24 Mon Sep 17 00:00:00 2001 From: SuriyaR Date: Mon, 12 Aug 2019 18:33:50 +0530 Subject: [PATCH 02/18] Changes --- server/controllers/BlockchainBlock.ts | 188 ++++++++------ server/socket/block.ts | 235 ++++++++++-------- .../graph-detail/graph-detail.component.html | 23 +- .../graph-detail/graph-detail.component.ts | 3 +- .../home/graph-list/graph-list.component.html | 136 +++++----- .../home/graph-list/graph-list.component.ts | 135 +++++----- 6 files changed, 402 insertions(+), 318 deletions(-) diff --git a/server/controllers/BlockchainBlock.ts b/server/controllers/BlockchainBlock.ts index f0bb6ce..9b7b4ac 100644 --- a/server/controllers/BlockchainBlock.ts +++ b/server/controllers/BlockchainBlock.ts @@ -1552,83 +1552,119 @@ export class BlockchainBlockController { }); let height = BlockchainLatestBlockQuery[0].height; + var coin_existence; + // if (height > 12960) { + // var remain_block = height - 12960; + // var coin_existence = + // 1440 * 200 + + // 1440 * 180 + + // 1440 * 160 + + // 1440 * 140 + + // 1440 * 120 + + // 1440 * 100 + + // 1440 * 80 + + // 1440 * 60 + + // 1440 * 50 + + // 25 * remain_block; + // } else if (height > 11520) { + // var remain_block = height - 11520; + // var coin_existence = + // 1440 * 200 + + // 1440 * 180 + + // 1440 * 160 + + // 1440 * 140 + + // 1440 * 120 + + // 1440 * 100 + + // 1440 * 80 + + // 1440 * 60 + + // remain_block * 50; + // } else if (height > 10080) { + // var remain_block = height - 10080; + // var coin_existence = + // 1440 * 200 + + // 1440 * 180 + + // 1440 * 160 + + // 1440 * 140 + + // 1440 * 120 + + // 1440 * 100 + + // 1440 * 80 + + // remain_block * 60; + // } else if (height > 8640) { + // var remain_block = height - 8640; + // var coin_existence = + // 1440 * 200 + + // 1440 * 180 + + // 1440 * 160 + + // 1440 * 140 + + // 1440 * 120 + + // 1440 * 100 + + // remain_block * 80; + // } else if (height > 7200) { + // var remain_block = height - 7200; + // var coin_existence = + // 1440 * 200 + + // 1440 * 180 + + // 1440 * 160 + + // 1440 * 140 + + // 1440 * 120 + + // remain_block * 100; + // } else if (height > 5760) { + // var remain_block = height - 5760; + // var coin_existence = + // 1440 * 200 + + // 1440 * 180 + + // 1440 * 160 + + // 1440 * 140 + + // remain_block * 120; + // } else if (height > 4320) { + // var remain_block = height - 4320; + // var coin_existence = + // 1440 * 200 + 1440 * 180 + 1440 * 160 + remain_block * 140; + // } else if (height > 2880) { + // var remain_block = height - 2880; + // var coin_existence = 1440 * 200 + 1440 * 180 + remain_block * 160; + // } else if (height > 1440) { + // var remain_block = height - 1440; + // var coin_existence = 1440 * 200 + remain_block * 180; + // } else { + // var coin_existence = height * 200; + // } + + let DAY_HEIGHT = 1440 +/// Height of the first epic block emission era +const BLOCK_ERA_1 = DAY_HEIGHT * 334; +/// Height of the second epic block emission era +const BLOCK_ERA_2 = BLOCK_ERA_1 + (DAY_HEIGHT * 470); +/// Height of the third epic block emission era +const BLOCK_ERA_3 = BLOCK_ERA_2 + (DAY_HEIGHT * 601); +/// Height of the fourth epic block emission era +const BLOCK_ERA_4 = BLOCK_ERA_3 + (DAY_HEIGHT * 800); +/// Height of the fifth epic block emission era +const BLOCK_ERA_5 = BLOCK_ERA_4 + (DAY_HEIGHT * 1019); +/// After the epic block emission era 6, each era will last 4 years (approximately 1460 days) +const BLOCK_ERA_6_ONWARDS = DAY_HEIGHT * 1460; +/// Block Reward that will be assigned after we change from era 5 to era 6. +const BASE_REWARD_ERA_6_ONWARDS = 0.15625; - if (height > 12960) { - var remain_block = height - 12960; - var coin_existence = - 1440 * 200 + - 1440 * 180 + - 1440 * 160 + - 1440 * 140 + - 1440 * 120 + - 1440 * 100 + - 1440 * 80 + - 1440 * 60 + - 1440 * 50 + - 25 * remain_block; - } else if (height > 11520) { - var remain_block = height - 11520; - var coin_existence = - 1440 * 200 + - 1440 * 180 + - 1440 * 160 + - 1440 * 140 + - 1440 * 120 + - 1440 * 100 + - 1440 * 80 + - 1440 * 60 + - remain_block * 50; - } else if (height > 10080) { - var remain_block = height - 10080; - var coin_existence = - 1440 * 200 + - 1440 * 180 + - 1440 * 160 + - 1440 * 140 + - 1440 * 120 + - 1440 * 100 + - 1440 * 80 + - remain_block * 60; - } else if (height > 8640) { - var remain_block = height - 8640; - var coin_existence = - 1440 * 200 + - 1440 * 180 + - 1440 * 160 + - 1440 * 140 + - 1440 * 120 + - 1440 * 100 + - remain_block * 80; - } else if (height > 7200) { - var remain_block = height - 7200; - var coin_existence = - 1440 * 200 + - 1440 * 180 + - 1440 * 160 + - 1440 * 140 + - 1440 * 120 + - remain_block * 100; - } else if (height > 5760) { - var remain_block = height - 5760; - var coin_existence = - 1440 * 200 + - 1440 * 180 + - 1440 * 160 + - 1440 * 140 + - remain_block * 120; - } else if (height > 4320) { - var remain_block = height - 4320; - var coin_existence = - 1440 * 200 + 1440 * 180 + 1440 * 160 + remain_block * 140; - } else if (height > 2880) { - var remain_block = height - 2880; - var coin_existence = 1440 * 200 + 1440 * 180 + remain_block * 160; - } else if (height > 1440) { - var remain_block = height - 1440; - var coin_existence = 1440 * 200 + remain_block * 180; - } else { - var coin_existence = height * 200; - } +/// Compute the total reward generated by each block in a given height. + if (height <= BLOCK_ERA_1) { + coin_existence = 16; + } else if (height <= BLOCK_ERA_2) { + coin_existence = 8; + } else if (height <= BLOCK_ERA_3) { + coin_existence = 4; + } else if (height <= BLOCK_ERA_4) { + coin_existence = 2; + } else if (height <= BLOCK_ERA_5) { + coin_existence = 1; + } else { + // After the era 6, we reduce the block rewards by half each 1460 days. + // Minus 1 to include multiples in the same index + // (i.e changes greater than to greater or equals to) + let height_with_offset = height - (BLOCK_ERA_5 - 1); + let exp = height_with_offset / BLOCK_ERA_6_ONWARDS; + coin_existence = BASE_REWARD_ERA_6_ONWARDS / (1 << exp); + } letest_block = this.dateDiff(BlockchainLatestBlockQuery[0].timestamp,true); letest_block_num = letest_block; // "72" diff --git a/server/socket/block.ts b/server/socket/block.ts index f542d2e..3eb3692 100644 --- a/server/socket/block.ts +++ b/server/socket/block.ts @@ -3,20 +3,20 @@ import { getConnection } from "typeorm"; var moment = require("moment"); moment.updateLocale('en', { relativeTime: { - future: "in %s", - past: "%s ago", - s: "seconds", - m: "1 minute", - mm: "%d minutes", - h: "1 hour", - hh: "%d hours", - d: "1 day", - dd: "%d days", - M: "1 month", - MM: "%d months", - y: "1 year", - yy: "%d years" - } + future: "in %s", + past: "%s ago", + s: "seconds", + m: "1 minute", + mm: "%d minutes", + h: "1 hour", + hh: "%d hours", + d: "1 day", + dd: "%d days", + M: "1 month", + MM: "%d months", + y: "1 year", + yy: "%d years" + } }); function dateDiff(date2, insec = false) { @@ -29,7 +29,7 @@ function dateDiff(date2, insec = false) { var enddayrnd = Math.round(enddaydif); // if(enddayrnd < 1) { var time = convertMinsToHrmin( - Math.abs(date2.getTime() - current_date.getTime()),insec + Math.abs(date2.getTime() - current_date.getTime()), insec ); return time; // } else if(enddayrnd == 1) { @@ -40,9 +40,9 @@ function dateDiff(date2, insec = false) { } -function convertMinsToHrmin(millseconds,insec) { +function convertMinsToHrmin(millseconds, insec) { var seconds = Math.floor(millseconds / 1000); - if(insec){ + if (insec) { let sec = Math.floor(millseconds / 1000); return sec; } @@ -81,83 +81,118 @@ export async function universalGetLatestBlockDetails(socket) { "SELECT bb.timestamp,bb.proof,bb.height,bb.edge_bits,bb.hash,bb.secondary_scaling, bb.previous_id, bb.total_difficulty_cuckaroo, bb.total_difficulty_cuckatoo, bb.total_difficulty_progpow, bb.total_difficulty_randomx, COUNT(DISTINCT(bi.block_id)) AS input_count, COUNT(DISTINCT(bk.block_id)) AS kernel_count, COUNT(DISTINCT(bo.block_id)) AS output_count FROM blockchain_block bb LEFT JOIN blockchain_input bi ON bi.block_id = bb.hash LEFT JOIN blockchain_kernel bk ON bk.block_id = bb.hash LEFT JOIN blockchain_output bo ON bo.block_id = bb.hash group by bb.hash, bb.timestamp ORDER BY bb.timestamp DESC LIMIT 1"); const BlockchainPreviousBlockQuery = await getConnection().query( "SELECT total_difficulty_cuckaroo, total_difficulty_cuckatoo, total_difficulty_progpow, total_difficulty_randomx FROM blockchain_block WHERE hash=" + - "'" + - BlockchainLatestBlockQuery[0].previous_id + - "'" + "'" + + BlockchainLatestBlockQuery[0].previous_id + + "'" ); let height = BlockchainLatestBlockQuery[0].height; - if (height > 12960) { - var remain_block = height - 12960; - var coin_existence = - 1440 * 200 + - 1440 * 180 + - 1440 * 160 + - 1440 * 140 + - 1440 * 120 + - 1440 * 100 + - 1440 * 80 + - 1440 * 60 + - 1440 * 50 + - 25 * remain_block; - } else if (height > 11520) { - var remain_block = height - 11520; - var coin_existence = - 1440 * 200 + - 1440 * 180 + - 1440 * 160 + - 1440 * 140 + - 1440 * 120 + - 1440 * 100 + - 1440 * 80 + - 1440 * 60 + - remain_block * 50; - } else if (height > 10080) { - var remain_block = height - 10080; - var coin_existence = - 1440 * 200 + - 1440 * 180 + - 1440 * 160 + - 1440 * 140 + - 1440 * 120 + - 1440 * 100 + - 1440 * 80 + - remain_block * 60; - } else if (height > 8640) { - var remain_block = height - 8640; - var coin_existence = - 1440 * 200 + - 1440 * 180 + - 1440 * 160 + - 1440 * 140 + - 1440 * 120 + - 1440 * 100 + - remain_block * 80; - } else if (height > 7200) { - var remain_block = height - 7200; - var coin_existence = - 1440 * 200 + - 1440 * 180 + - 1440 * 160 + - 1440 * 140 + - 1440 * 120 + - remain_block * 100; - } else if (height > 5760) { - var remain_block = height - 5760; - var coin_existence = - 1440 * 200 + 1440 * 180 + 1440 * 160 + 1440 * 140 + remain_block * 120; - } else if (height > 4320) { - var remain_block = height - 4320; - var coin_existence = - 1440 * 200 + 1440 * 180 + 1440 * 160 + remain_block * 140; - } else if (height > 2880) { - var remain_block = height - 2880; - var coin_existence = 1440 * 200 + 1440 * 180 + remain_block * 160; - } else if (height > 1440) { - var remain_block = height - 1440; - var coin_existence = 1440 * 200 + remain_block * 180; + // if (height > 12960) { + // var remain_block = height - 12960; + // var coin_existence = + // 1440 * 200 + + // 1440 * 180 + + // 1440 * 160 + + // 1440 * 140 + + // 1440 * 120 + + // 1440 * 100 + + // 1440 * 80 + + // 1440 * 60 + + // 1440 * 50 + + // 25 * remain_block; + // } else if (height > 11520) { + // var remain_block = height - 11520; + // var coin_existence = + // 1440 * 200 + + // 1440 * 180 + + // 1440 * 160 + + // 1440 * 140 + + // 1440 * 120 + + // 1440 * 100 + + // 1440 * 80 + + // 1440 * 60 + + // remain_block * 50; + // } else if (height > 10080) { + // var remain_block = height - 10080; + // var coin_existence = + // 1440 * 200 + + // 1440 * 180 + + // 1440 * 160 + + // 1440 * 140 + + // 1440 * 120 + + // 1440 * 100 + + // 1440 * 80 + + // remain_block * 60; + // } else if (height > 8640) { + // var remain_block = height - 8640; + // var coin_existence = + // 1440 * 200 + + // 1440 * 180 + + // 1440 * 160 + + // 1440 * 140 + + // 1440 * 120 + + // 1440 * 100 + + // remain_block * 80; + // } else if (height > 7200) { + // var remain_block = height - 7200; + // var coin_existence = + // 1440 * 200 + + // 1440 * 180 + + // 1440 * 160 + + // 1440 * 140 + + // 1440 * 120 + + // remain_block * 100; + // } else if (height > 5760) { + // var remain_block = height - 5760; + // var coin_existence = + // 1440 * 200 + 1440 * 180 + 1440 * 160 + 1440 * 140 + remain_block * 120; + // } else if (height > 4320) { + // var remain_block = height - 4320; + // var coin_existence = + // 1440 * 200 + 1440 * 180 + 1440 * 160 + remain_block * 140; + // } else if (height > 2880) { + // var remain_block = height - 2880; + // var coin_existence = 1440 * 200 + 1440 * 180 + remain_block * 160; + // } else if (height > 1440) { + // var remain_block = height - 1440; + // var coin_existence = 1440 * 200 + remain_block * 180; + // } else { + // var coin_existence = height * 200; + // } + var coin_existence; + let DAY_HEIGHT = 1440 + /// Height of the first epic block emission era + const BLOCK_ERA_1 = DAY_HEIGHT * 334; + /// Height of the second epic block emission era + const BLOCK_ERA_2 = BLOCK_ERA_1 + (DAY_HEIGHT * 470); + /// Height of the third epic block emission era + const BLOCK_ERA_3 = BLOCK_ERA_2 + (DAY_HEIGHT * 601); + /// Height of the fourth epic block emission era + const BLOCK_ERA_4 = BLOCK_ERA_3 + (DAY_HEIGHT * 800); + /// Height of the fifth epic block emission era + const BLOCK_ERA_5 = BLOCK_ERA_4 + (DAY_HEIGHT * 1019); + /// After the epic block emission era 6, each era will last 4 years (approximately 1460 days) + const BLOCK_ERA_6_ONWARDS = DAY_HEIGHT * 1460; + /// Block Reward that will be assigned after we change from era 5 to era 6. + const BASE_REWARD_ERA_6_ONWARDS = 0.15625; + /// Compute the total reward generated by each block in a given height. + if (height <= BLOCK_ERA_1) { + coin_existence = 16; + } else if (height <= BLOCK_ERA_2) { + coin_existence = 8; + } else if (height <= BLOCK_ERA_3) { + coin_existence = 4; + } else if (height <= BLOCK_ERA_4) { + coin_existence = 2; + } else if (height <= BLOCK_ERA_5) { + coin_existence = 1; } else { - var coin_existence = height * 200; + // After the era 6, we reduce the block rewards by half each 1460 days. + // Minus 1 to include multiples in the same index + // (i.e changes greater than to greater or equals to) + let height_with_offset = height - (BLOCK_ERA_5 - 1); + let exp = height_with_offset / BLOCK_ERA_6_ONWARDS; + coin_existence = BASE_REWARD_ERA_6_ONWARDS / (1 << exp); } letest_block = dateDiff(BlockchainLatestBlockQuery[0].timestamp, true); @@ -200,11 +235,11 @@ export async function universalGetLatestBlockDetails(socket) { BlockchainPreviousBlockQuery[0].total_difficulty_randomx; } - if(BlockchainLatestBlockQuery[0].proof == "RandomX"){ - var Difficulty = targetdifficultyrandomx; - }else if(BlockchainLatestBlockQuery[0].proof == "ProgPow"){ + if (BlockchainLatestBlockQuery[0].proof == "RandomX") { + var Difficulty = targetdifficultyrandomx; + } else if (BlockchainLatestBlockQuery[0].proof == "ProgPow") { var Difficulty = targetdifficultyprogpow; - }else if(BlockchainLatestBlockQuery[0].proof == "Cuckoo" ){ + } else if (BlockchainLatestBlockQuery[0].proof == "Cuckoo") { var Difficulty = targetdifficultycuckatoo; } @@ -214,9 +249,9 @@ export async function universalGetLatestBlockDetails(socket) { var TotalCuckoo = parseInt(BlockchainLatestBlockQuery[0].total_difficulty_cuckatoo) + parseInt(BlockchainLatestBlockQuery[0].total_difficulty_cuckaroo); - let balance = BlockchainLatestBlockQuery[0].hash.substring(2, 62); - let arr = balance.match(/.{1,6}/g); - var hasharray = arr.map(i => '#' + i); + let balance = BlockchainLatestBlockQuery[0].hash.substring(2, 62); + let arr = balance.match(/.{1,6}/g); + var hasharray = arr.map(i => '#' + i); socket.emit("latestblockdetail", { block_height, @@ -230,7 +265,7 @@ export async function universalGetLatestBlockDetails(socket) { targetdifficultyprogpow, targetdifficultyrandomx, TotalCuckoo, - age : dateTimeDurationString, + age: dateTimeDurationString, input_count: BlockchainLatestBlockQuery[0].input_count, kernel_count: BlockchainLatestBlockQuery[0].kernel_count, output_count: BlockchainLatestBlockQuery[0].output_count, @@ -238,8 +273,8 @@ export async function universalGetLatestBlockDetails(socket) { proof: BlockchainLatestBlockQuery[0].proof, hasharray: hasharray, Difficulty: Difficulty, - hashstart:BlockchainLatestBlockQuery[0].hash.slice(0, 2), - hashend:BlockchainLatestBlockQuery[0].hash.slice(62,64), + hashstart: BlockchainLatestBlockQuery[0].hash.slice(0, 2), + hashend: BlockchainLatestBlockQuery[0].hash.slice(62, 64), TotalDifficultyCuckaroo: BlockchainLatestBlockQuery[0].total_difficulty_cuckaroo, TotalDifficultyCuckatoo: diff --git a/src/app/view/graph-view/graph-detail/graph-detail.component.html b/src/app/view/graph-view/graph-detail/graph-detail.component.html index 8ed5bbf..ffd3909 100644 --- a/src/app/view/graph-view/graph-detail/graph-detail.component.html +++ b/src/app/view/graph-view/graph-detail/graph-detail.component.html @@ -69,6 +69,9 @@ {{chartType | translate}} @@ -152,8 +157,6 @@ diff --git a/src/app/view/graph-view/graph-detail/graph-detail.component.ts b/src/app/view/graph-view/graph-detail/graph-detail.component.ts index 45dac8f..6c2702b 100644 --- a/src/app/view/graph-view/graph-detail/graph-detail.component.ts +++ b/src/app/view/graph-view/graph-detail/graph-detail.component.ts @@ -23,7 +23,7 @@ export class GraphDetailComponent implements OnInit { public chartType : any = []; public selectedItem: Number = 3; public selectedItem8: Number = 2; - public selectedItem12: Number = 1; + public selectedItem12: Number = 4; public Type: any = ''; public selectedTarget: Number = 3; public selectedTarget12: Number = 1; @@ -34,7 +34,6 @@ export class GraphDetailComponent implements OnInit { public GraphtDate: any; public GraphtHour: any; public linearTotalGraphData: any = []; - public TdifficultyRange: any = '1 day'; constructor( private route: ActivatedRoute, diff --git a/src/app/view/home/graph-list/graph-list.component.html b/src/app/view/home/graph-list/graph-list.component.html index 6616ecf..cae6cc1 100644 --- a/src/app/view/home/graph-list/graph-list.component.html +++ b/src/app/view/home/graph-list/graph-list.component.html @@ -1,68 +1,4 @@
-
-
-
-

{{'home.TARGET_DIFFICULTY' | translate}}

- - -
- - - - -
-
- - - -
-
@@ -74,6 +10,10 @@
All + Cuckoo @@ -308,7 +248,7 @@
-
+

{{'home.BLOCKS_MINED' | translate}}

@@ -581,5 +521,71 @@
--> +
+
+
+

{{'home.TARGET_DIFFICULTY' | translate}}

+ + +
+ + + + +
+
+ + +
+
diff --git a/src/app/view/home/graph-list/graph-list.component.ts b/src/app/view/home/graph-list/graph-list.component.ts index 5f3a139..d6f3148 100644 --- a/src/app/view/home/graph-list/graph-list.component.ts +++ b/src/app/view/home/graph-list/graph-list.component.ts @@ -50,16 +50,16 @@ export class GraphListComponent implements OnInit { public selectedItem9: Number = 3; public selectedItem10: Number = 3; public selectedItem11: Number = 3; - public selectedItem12: Number = 1; + public selectedItem12: Number = 4; public selectedTarget: Number = 6; - public selectedTarget12: Number = 1; + public selectedTarget12: Number = 4; public tInput: any; public tOutput: any; public tKernal: any; public tDate: any; public tHour: any; - public Type: any = ''; + public Type: any = 'all'; public difficultyRange: any = '1 day'; public TdifficultyRange: any = '1 day'; @@ -386,7 +386,7 @@ export class GraphListComponent implements OnInit { interval = '', type = '' ) { - this.Type = type != '' ? type : this.Type == '' ? 'cuckatoo' : this.Type; + this.Type = type != '' ? type : this.Type == '' ? 'all' : this.Type; return new Promise((resolve, reject) => { let params = new HttpParams(); params = params.append('FromDate', fromDate); @@ -400,18 +400,73 @@ export class GraphListComponent implements OnInit { res => { if (res['status'] == 200) { let DifficultychartDate = res.response.Date; - let BlocksChartDate = res.response.blockDate; - let TargetDifficulty = res.response.TargetDifficulty; + let DifficultyCuckatoo = res.response.DifficultyCuckatoo; + let DifficultyRandomx = res.response.DifficultyRandomx; + let DifficultyProgpow = res.response.DifficultyProgpow; + let data; + switch(this.Type) { + case 'all': + data = + [ + { + x: DifficultychartDate, + y: DifficultyCuckatoo, + text: DifficultychartDate, + mode: 'lines+markers', + type: 'scatter', + name: '', + line: { color: '#ac3333' }, + hovertemplate: '%{text}
Cuckoo : %{y:,}', + }, + { + x: DifficultychartDate, + y: DifficultyProgpow, + text: DifficultychartDate, + mode: 'lines+markers', + type: 'scatter', + name: '', + line: { color: '#ac3333' }, + hovertemplate: '%{text}
Progpow : %{y:,}', + }, + { + x: DifficultychartDate, + y: DifficultyRandomx, + text: DifficultychartDate, + mode: 'lines+markers', + type: 'scatter', + name: '', + line: { color: '#ac3333' }, + hovertemplate: '%{text}
RandomX : %{y:,}', + }, + ]; + break; + default: + let yvalue = this.Type == 'cuckatoo' ? DifficultyCuckatoo : this.Type == 'progpow' ? DifficultyProgpow : this.Type == 'randomx' ? DifficultyRandomx : [] + data = + [ + { + x: DifficultychartDate, + y: yvalue, + text: DifficultychartDate, + mode: 'lines+markers', + type: 'scatter', + name: '', + line: { color: '#ac3333' }, + hovertemplate: '%{text}
Difficulty : %{y:,}', + }]; + break; + } + let range = [res.response.Minrange, res.response.Maxrange] let tickformat = res.response.tickFormat; - this.lg_last = - TargetDifficulty[TargetDifficulty.length - 1]; + // this.lg_last = + // TargetDifficulty[TargetDifficulty.length - 1]; switch(difftype){ case 'total': this.totaldifficultyChartFunc( DifficultychartDate, - TargetDifficulty, + data, this.Type, range, tickformat @@ -420,7 +475,7 @@ export class GraphListComponent implements OnInit { case 'target': this.difficultyChartFunc( DifficultychartDate, - TargetDifficulty, + data, this.Type, range, tickformat @@ -463,51 +518,10 @@ export class GraphListComponent implements OnInit { }); } - difficultyChartFunc(DifficultychartDate, TargetDifficulty, Type, range, tickformat) { + difficultyChartFunc(DifficultychartDate, data, Type, range, tickformat) { // console.log('range rangerangerange',range); this.linearGraphData = { - data: [ - { - x: DifficultychartDate, - y: TargetDifficulty, - text: DifficultychartDate, - mode: 'lines+markers', - type: 'scatter', - name: '', - line: { color: '#ac3333' }, - hovertemplate: '%{text}
Difficulty : %{y:,}', - }, - // { - // x: DifficultychartDate, - // y: DifficultyCuckatoo, - // text: DifficultyCuckatoo, - // mode: 'lines+markers', - // type: 'scatter', - // name: '', - // line: { color: '#A876C6' }, - // hovertemplate: '%{x}
Cuckatoo : %{text:,}', - // }, - // { - // x: DifficultychartDate, - // y: DifficultyProgpow, - // text: DifficultyProgpow, - // mode: 'lines+markers', - // type: 'scatter', - // name: '', - // line: { color: '#54CFDC' }, - // hovertemplate: '%{x}
Progpow : %{text:,}', - // }, - // { - // x: DifficultychartDate, - // y: DifficultyRandomx, - // text: DifficultyRandomx, - // mode: 'lines+markers', - // type: 'scatter', - // name: '', - // line: { color: '#77817C' }, - // hovertemplate: '%{x}
Randomx : %{text:,}', - // }, - ], + data: data , layout: { hovermode: 'closest', height: 250, @@ -1091,20 +1105,9 @@ export class GraphListComponent implements OnInit { options: null, }; } - totaldifficultyChartFunc(DifficultychartDate, TargetDifficulty, Type, range, tickformat) { + totaldifficultyChartFunc(DifficultychartDate, data, type, range, tickformat) { this.linearTotalGraphData = { - data: [ - { - x: DifficultychartDate, - y: TargetDifficulty, - text: DifficultychartDate, - mode: 'lines+markers', - type: 'scatter', - name: '', - line: { color: '#ac3333' }, - hovertemplate: '%{text}
Difficulty : %{y:,}', - }, - ], + data: data, layout: { hovermode: 'closest', height: 250, From 3f0400645300328dea2f04365fb658c60af7b0e9 Mon Sep 17 00:00:00 2001 From: SuriyaR Date: Mon, 12 Aug 2019 19:03:58 +0530 Subject: [PATCH 03/18] Changes --- server/i18n/de.json | 1 + server/i18n/en.json | 1 + .../view/home/latestblocks/latestblocks.component.html | 10 +++++----- 3 files changed, 7 insertions(+), 5 deletions(-) diff --git a/server/i18n/de.json b/server/i18n/de.json index d63a9c1..606ebf5 100644 --- a/server/i18n/de.json +++ b/server/i18n/de.json @@ -17,6 +17,7 @@ "EXPLORE_IT": "Entdecke", "VIEWALL": "Alle Diagramme anzeigen", "BLOCKCHAIN_HEIGHT": "Blockchain Höhe", + "LATEST_BLOCKS" : "Letzter Blocks", "LATEST_BLOCK": "Letzter Block", "LATEST_BLOCK1": "Aktuelle Zielschwierigkeit", "LATEST_BLOCK2": "Aktuelle Gesamtschwierigkeit", diff --git a/server/i18n/en.json b/server/i18n/en.json index 4685ce7..4d71e11 100644 --- a/server/i18n/en.json +++ b/server/i18n/en.json @@ -17,6 +17,7 @@ "EXPLORE_IT": "Explore", "VIEWALL": "View All Charts", "BLOCKCHAIN_HEIGHT": "Blockchain Height", + "LATEST_BLOCKS" : "Latest Blocks", "LATEST_BLOCK": "Latest Block", "LATEST_BLOCK1": "Current Target Difficulty", "LATEST_BLOCK2": "Current Total Difficulty", diff --git a/src/app/view/home/latestblocks/latestblocks.component.html b/src/app/view/home/latestblocks/latestblocks.component.html index b2fd220..2605407 100644 --- a/src/app/view/home/latestblocks/latestblocks.component.html +++ b/src/app/view/home/latestblocks/latestblocks.component.html @@ -1,5 +1,5 @@
-

{{'home.LATEST_BLOCK' | translate}}

+

{{'home.LATEST_BLOCKS' | translate}}

@@ -46,9 +46,9 @@
- -
+ +
@@ -108,7 +108,7 @@
-->
- +
From 8d8e9de3d27b08449d32d54b44babe3467fd3b46 Mon Sep 17 00:00:00 2001 From: root Date: Mon, 12 Aug 2019 19:04:30 +0530 Subject: [PATCH 04/18] socket.io --- src/app/shared/services/chart.service.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/app/shared/services/chart.service.ts b/src/app/shared/services/chart.service.ts index a0325dd..41b9a98 100644 --- a/src/app/shared/services/chart.service.ts +++ b/src/app/shared/services/chart.service.ts @@ -17,7 +17,7 @@ export class ChartService { private socket; constructor(public http: HttpClient) { - this.socket = io.connect(this.server); + this.socket = io.connect(this.server, {transports: ['websocket']}); } // public createSocketConnection() { From 18b9a275078bf567d3148e520a2b0effbc982dce Mon Sep 17 00:00:00 2001 From: root Date: Mon, 12 Aug 2019 19:24:40 +0530 Subject: [PATCH 05/18] socket.io --- server.ts | 6 +++--- src/app/shared/services/chart.service.ts | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/server.ts b/server.ts index 4c8cff4..4010b60 100644 --- a/server.ts +++ b/server.ts @@ -149,9 +149,9 @@ connection }); const io = require("socket.io").listen(server); io.sockets.on("connection", socket => { - setInterval(function() { - universalGetLatestBlockDetails(socket); - },1000); + // setInterval(function() { + // //universalGetLatestBlockDetails(socket); + // },1000); }); }) .catch(error => { diff --git a/src/app/shared/services/chart.service.ts b/src/app/shared/services/chart.service.ts index 41b9a98..a0325dd 100644 --- a/src/app/shared/services/chart.service.ts +++ b/src/app/shared/services/chart.service.ts @@ -17,7 +17,7 @@ export class ChartService { private socket; constructor(public http: HttpClient) { - this.socket = io.connect(this.server, {transports: ['websocket']}); + this.socket = io.connect(this.server); } // public createSocketConnection() { From 95377bd3804dfcc3a387de28d86baaaf6737f721 Mon Sep 17 00:00:00 2001 From: SuriyaR Date: Mon, 12 Aug 2019 19:25:18 +0530 Subject: [PATCH 06/18] Changes --- server/controllers/BlockchainBlock.ts | 98 +++++++++++++++++++-------- server/socket/block.ts | 46 ++++++++----- 2 files changed, 99 insertions(+), 45 deletions(-) diff --git a/server/controllers/BlockchainBlock.ts b/server/controllers/BlockchainBlock.ts index 0f409f9..be74a4c 100644 --- a/server/controllers/BlockchainBlock.ts +++ b/server/controllers/BlockchainBlock.ts @@ -741,27 +741,62 @@ export class BlockchainBlockController { // } BlockchainBlockFetchQuery['TotalCuckoo']=parseInt(BlockchainBlockFetchQuery.TotalDifficultyCuckaroo) + parseInt(BlockchainBlockFetchQuery.TotalDifficultyCuckatoo); - if (BlockchainBlockFetchQuery.Height <= 1440) { - BlockchainBlockFetchQuery['BlockReward'] = 200; - } else if (BlockchainBlockFetchQuery.Height <= 2880) { - BlockchainBlockFetchQuery['BlockReward'] = 180; - } else if (BlockchainBlockFetchQuery.Height <= 4320) { - BlockchainBlockFetchQuery['BlockReward'] = 160; - } else if (BlockchainBlockFetchQuery.Height <= 5760) { - BlockchainBlockFetchQuery['BlockReward'] = 140; - } else if (BlockchainBlockFetchQuery.Height <= 7200) { - BlockchainBlockFetchQuery['BlockReward'] = 120; - } else if (BlockchainBlockFetchQuery.Height <= 8640) { - BlockchainBlockFetchQuery['BlockReward'] = 100; - } else if (BlockchainBlockFetchQuery.Height <= 10080) { - BlockchainBlockFetchQuery['BlockReward'] = 80; - } else if (BlockchainBlockFetchQuery.Height <= 11520) { - BlockchainBlockFetchQuery['BlockReward'] = 60; - } else if (BlockchainBlockFetchQuery.Height <= 12960) { - BlockchainBlockFetchQuery['BlockReward'] = 50; - } else { - BlockchainBlockFetchQuery['BlockReward'] = 25; - } + var coin_existence; + let DAY_HEIGHT = 1440 + /// Height of the first epic block emission era + const BLOCK_ERA_1 = DAY_HEIGHT * 334; + /// Height of the second epic block emission era + const BLOCK_ERA_2 = BLOCK_ERA_1 + (DAY_HEIGHT * 470); + /// Height of the third epic block emission era + const BLOCK_ERA_3 = BLOCK_ERA_2 + (DAY_HEIGHT * 601); + /// Height of the fourth epic block emission era + const BLOCK_ERA_4 = BLOCK_ERA_3 + (DAY_HEIGHT * 800); + /// Height of the fifth epic block emission era + const BLOCK_ERA_5 = BLOCK_ERA_4 + (DAY_HEIGHT * 1019); + /// After the epic block emission era 6, each era will last 4 years (approximately 1460 days) + const BLOCK_ERA_6_ONWARDS = DAY_HEIGHT * 1460; + /// Block Reward that will be assigned after we change from era 5 to era 6. + const BASE_REWARD_ERA_6_ONWARDS = 0.15625; + /// Compute the total reward generated by each block in a given height. + if (BlockchainBlockFetchQuery.Height <= BLOCK_ERA_1) { + BlockchainBlockFetchQuery['BlockReward'] = 16; + } else if (BlockchainBlockFetchQuery.Height <= BLOCK_ERA_2) { + BlockchainBlockFetchQuery['BlockReward'] = 8; + } else if (BlockchainBlockFetchQuery.Height <= BLOCK_ERA_3) { + BlockchainBlockFetchQuery['BlockReward'] = 4; + } else if (BlockchainBlockFetchQuery.Height <= BLOCK_ERA_4) { + BlockchainBlockFetchQuery['BlockReward'] = 2; + } else if (BlockchainBlockFetchQuery.Height <= BLOCK_ERA_5) { + BlockchainBlockFetchQuery['BlockReward'] = 1; + } else { + // After the era 6, we reduce the block rewards by half each 1460 days. + // Minus 1 to include multiples in the same index + // (i.e changes greater than to greater or equals to) + let height_with_offset = BlockchainBlockFetchQuery.Height - (BLOCK_ERA_5 - 1); + let exp = height_with_offset / BLOCK_ERA_6_ONWARDS; + BlockchainBlockFetchQuery['BlockReward'] = BASE_REWARD_ERA_6_ONWARDS / (1 << exp); + } + // if (BlockchainBlockFetchQuery.Height <= 1440) { + // BlockchainBlockFetchQuery['BlockReward'] = 200; + // } else if (BlockchainBlockFetchQuery.Height <= 2880) { + // BlockchainBlockFetchQuery['BlockReward'] = 180; + // } else if (BlockchainBlockFetchQuery.Height <= 4320) { + // BlockchainBlockFetchQuery['BlockReward'] = 160; + // } else if (BlockchainBlockFetchQuery.Height <= 5760) { + // BlockchainBlockFetchQuery['BlockReward'] = 140; + // } else if (BlockchainBlockFetchQuery.Height <= 7200) { + // BlockchainBlockFetchQuery['BlockReward'] = 120; + // } else if (BlockchainBlockFetchQuery.Height <= 8640) { + // BlockchainBlockFetchQuery['BlockReward'] = 100; + // } else if (BlockchainBlockFetchQuery.Height <= 10080) { + // BlockchainBlockFetchQuery['BlockReward'] = 80; + // } else if (BlockchainBlockFetchQuery.Height <= 11520) { + // BlockchainBlockFetchQuery['BlockReward'] = 60; + // } else if (BlockchainBlockFetchQuery.Height <= 12960) { + // BlockchainBlockFetchQuery['BlockReward'] = 50; + // } else { + // BlockchainBlockFetchQuery['BlockReward'] = 25; + // } if (BlockchainBlockFetchQuery.PreviousId) { const BlockchainPreviousBlockFetchQuery = await getRepository( @@ -1643,24 +1678,33 @@ const BLOCK_ERA_6_ONWARDS = DAY_HEIGHT * 1460; /// Block Reward that will be assigned after we change from era 5 to era 6. const BASE_REWARD_ERA_6_ONWARDS = 0.15625; +let remaining_height = 0; /// Compute the total reward generated by each block in a given height. if (height <= BLOCK_ERA_1) { - coin_existence = 16; + coin_existence = height * 16; } else if (height <= BLOCK_ERA_2) { - coin_existence = 8; + remaining_height = height - BLOCK_ERA_1; + coin_existence = (16 * BLOCK_ERA_1) + 8 * remaining_height; } else if (height <= BLOCK_ERA_3) { - coin_existence = 4; + remaining_height = height - BLOCK_ERA_2; + coin_existence = (16 * BLOCK_ERA_1) + (8 * BLOCK_ERA_2) + 4 * remaining_height; } else if (height <= BLOCK_ERA_4) { - coin_existence = 2; + remaining_height = height - BLOCK_ERA_3; + coin_existence = (16 * BLOCK_ERA_1) + (8 * BLOCK_ERA_2) + (4 * BLOCK_ERA_3) + 2 * remaining_height; } else if (height <= BLOCK_ERA_5) { - coin_existence = 1; + remaining_height = height - BLOCK_ERA_4; + coin_existence = (16 * BLOCK_ERA_1) + (8 * BLOCK_ERA_2) + (4 * BLOCK_ERA_3) + (2 * BLOCK_ERA_4) +1 * remaining_height; } else { // After the era 6, we reduce the block rewards by half each 1460 days. // Minus 1 to include multiples in the same index // (i.e changes greater than to greater or equals to) + + let preious_circulation = (16 * BLOCK_ERA_1) + (8 * BLOCK_ERA_2) + (4 * BLOCK_ERA_3) + (2 * BLOCK_ERA_4) + (1 * BLOCK_ERA_5); + let height_with_offset = height - (BLOCK_ERA_5 - 1); let exp = height_with_offset / BLOCK_ERA_6_ONWARDS; - coin_existence = BASE_REWARD_ERA_6_ONWARDS / (1 << exp); + let reward_emission = BASE_REWARD_ERA_6_ONWARDS / (1 << exp); + coin_existence = preious_circulation + reward_emission ; } letest_block = this.dateDiff(BlockchainLatestBlockQuery[0].timestamp,true); diff --git a/server/socket/block.ts b/server/socket/block.ts index 3eb3692..efb9da2 100644 --- a/server/socket/block.ts +++ b/server/socket/block.ts @@ -175,25 +175,35 @@ export async function universalGetLatestBlockDetails(socket) { const BLOCK_ERA_6_ONWARDS = DAY_HEIGHT * 1460; /// Block Reward that will be assigned after we change from era 5 to era 6. const BASE_REWARD_ERA_6_ONWARDS = 0.15625; + + let remaining_height = 0; /// Compute the total reward generated by each block in a given height. - if (height <= BLOCK_ERA_1) { - coin_existence = 16; - } else if (height <= BLOCK_ERA_2) { - coin_existence = 8; - } else if (height <= BLOCK_ERA_3) { - coin_existence = 4; - } else if (height <= BLOCK_ERA_4) { - coin_existence = 2; - } else if (height <= BLOCK_ERA_5) { - coin_existence = 1; - } else { - // After the era 6, we reduce the block rewards by half each 1460 days. - // Minus 1 to include multiples in the same index - // (i.e changes greater than to greater or equals to) - let height_with_offset = height - (BLOCK_ERA_5 - 1); - let exp = height_with_offset / BLOCK_ERA_6_ONWARDS; - coin_existence = BASE_REWARD_ERA_6_ONWARDS / (1 << exp); - } + if (height <= BLOCK_ERA_1) { + coin_existence = height * 16; + } else if (height <= BLOCK_ERA_2) { + remaining_height = height - BLOCK_ERA_1; + coin_existence = (16 * BLOCK_ERA_1) + 8 * remaining_height; + } else if (height <= BLOCK_ERA_3) { + remaining_height = height - BLOCK_ERA_2; + coin_existence = (16 * BLOCK_ERA_1) + (8 * BLOCK_ERA_2) + 4 * remaining_height; + } else if (height <= BLOCK_ERA_4) { + remaining_height = height - BLOCK_ERA_3; + coin_existence = (16 * BLOCK_ERA_1) + (8 * BLOCK_ERA_2) + (4 * BLOCK_ERA_3) + 2 * remaining_height; + } else if (height <= BLOCK_ERA_5) { + remaining_height = height - BLOCK_ERA_4; + coin_existence = (16 * BLOCK_ERA_1) + (8 * BLOCK_ERA_2) + (4 * BLOCK_ERA_3) + (2 * BLOCK_ERA_4) +1 * remaining_height; + } else { + // After the era 6, we reduce the block rewards by half each 1460 days. + // Minus 1 to include multiples in the same index + // (i.e changes greater than to greater or equals to) + + let preious_circulation = (16 * BLOCK_ERA_1) + (8 * BLOCK_ERA_2) + (4 * BLOCK_ERA_3) + (2 * BLOCK_ERA_4) + (1 * BLOCK_ERA_5); + + let height_with_offset = height - (BLOCK_ERA_5 - 1); + let exp = height_with_offset / BLOCK_ERA_6_ONWARDS; + let reward_emission = BASE_REWARD_ERA_6_ONWARDS / (1 << exp); + coin_existence = preious_circulation + reward_emission ; + } letest_block = dateDiff(BlockchainLatestBlockQuery[0].timestamp, true); letest_block_num = letest_block // "72" From a23d1e408f256e36f4d3516e8254ab64bba5130f Mon Sep 17 00:00:00 2001 From: SuriyaR Date: Mon, 12 Aug 2019 19:34:13 +0530 Subject: [PATCH 07/18] Changes --- .../view/block-view/block-detail/block-detail.component.html | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/app/view/block-view/block-detail/block-detail.component.html b/src/app/view/block-view/block-detail/block-detail.component.html index 368cbc0..ca37ca1 100644 --- a/src/app/view/block-view/block-detail/block-detail.component.html +++ b/src/app/view/block-view/block-detail/block-detail.component.html @@ -68,8 +68,8 @@
-
Target Difficulty - {{(hashdata.BlockchainBlockFetchQuery.Proof == 'Cuckoo') ? (hashdata.BlockchainBlockFetchQuery.TargetDifficultyCuckatoo | number) : (hashdata.BlockchainBlockFetchQuery.Proof == 'RandomX') ? (hashdata.BlockchainBlockFetchQuery.TargetDifficultyRandomx | number) : (hashdata.BlockchainBlockFetchQuery.Proof == 'ProgPow') ? (hashdata.BlockchainBlockFetchQuery.TargetDifficultyProgpow | number) : 0}}
+
Total Difficulty {{(hashdata.BlockchainBlockFetchQuery.Proof == 'Cuckoo') ? (hashdata.BlockchainBlockFetchQuery.TotalDifficultyCuckatoo | number) : (hashdata.BlockchainBlockFetchQuery.Proof == 'RandomX') ? (hashdata.BlockchainBlockFetchQuery.TotalDifficultyRandomx | number) : (hashdata.BlockchainBlockFetchQuery.Proof == 'ProgPow') ? (hashdata.BlockchainBlockFetchQuery.TotalDifficultyProgpow | number) : 0}}
From 70bf81782ee71465bf37dff1f23e4d6dc98db4cf Mon Sep 17 00:00:00 2001 From: SuriyaR Date: Mon, 12 Aug 2019 19:47:11 +0530 Subject: [PATCH 08/18] Peers count --- src/app/view/home/latestblocks/latestblocks.component.html | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/app/view/home/latestblocks/latestblocks.component.html b/src/app/view/home/latestblocks/latestblocks.component.html index 2605407..a2b3c10 100644 --- a/src/app/view/home/latestblocks/latestblocks.component.html +++ b/src/app/view/home/latestblocks/latestblocks.component.html @@ -163,7 +163,9 @@
-

Peers

+

Peers {{ + peers.length | number + }}

From 6c79281e8f7962316f0f3635043b1095b8951b1a Mon Sep 17 00:00:00 2001 From: SuriyaR Date: Tue, 13 Aug 2019 12:49:23 +0530 Subject: [PATCH 09/18] Peers error and supply growth error fixed --- server/controllers/BlockchainBlock.ts | 63 ++++++++++++++----- .../latestblocks/latestblocks.component.html | 6 +- .../latestblocks/latestblocks.component.ts | 6 +- 3 files changed, 58 insertions(+), 17 deletions(-) diff --git a/server/controllers/BlockchainBlock.ts b/server/controllers/BlockchainBlock.ts index be74a4c..77c23ce 100644 --- a/server/controllers/BlockchainBlock.ts +++ b/server/controllers/BlockchainBlock.ts @@ -707,7 +707,7 @@ export class BlockchainBlockController { 'SecondaryScaling', 'Proof', ], - where: { Height: paramVal }, + where: { Height: paramVal }, }); } if (!BlockchainBlockFetchQuery) { @@ -758,7 +758,9 @@ export class BlockchainBlockController { /// Block Reward that will be assigned after we change from era 5 to era 6. const BASE_REWARD_ERA_6_ONWARDS = 0.15625; /// Compute the total reward generated by each block in a given height. - if (BlockchainBlockFetchQuery.Height <= BLOCK_ERA_1) { + if(BlockchainBlockFetchQuery.Height == 0) { + BlockchainBlockFetchQuery['BlockReward'] = 0; + }else if (BlockchainBlockFetchQuery.Height <= BLOCK_ERA_1) { BlockchainBlockFetchQuery['BlockReward'] = 16; } else if (BlockchainBlockFetchQuery.Height <= BLOCK_ERA_2) { BlockchainBlockFetchQuery['BlockReward'] = 8; @@ -1867,23 +1869,34 @@ let remaining_height = 0; } else { var timeIntervalQry = "timestamp > current_date - interval '30 days'"; } + let DAY_HEIGHT = 1440 + /// Height of the first epic block emission era + const BLOCK_ERA_1 = DAY_HEIGHT * 334; + /// Height of the second epic block emission era + const BLOCK_ERA_2 = BLOCK_ERA_1 + (DAY_HEIGHT * 470); + /// Height of the third epic block emission era + const BLOCK_ERA_3 = BLOCK_ERA_2 + (DAY_HEIGHT * 601); + /// Height of the fourth epic block emission era + const BLOCK_ERA_4 = BLOCK_ERA_3 + (DAY_HEIGHT * 800); + /// Height of the fifth epic block emission era + const BLOCK_ERA_5 = BLOCK_ERA_4 + (DAY_HEIGHT * 1019); + /// After the epic block emission era 6, each era will last 4 years (approximately 1460 days) + const BLOCK_ERA_6_ONWARDS = DAY_HEIGHT * 1460; + /// Block Reward that will be assigned after we change from era 5 to era 6. + const BASE_REWARD_ERA_6_ONWARDS = 0.15625; const BlockchainBlockPerSecondQuery = await getConnection() .query( - 'select x.timestamp, SUM(x.reward) as total_reward_per_day \ + 'select x.timestamp, x.height, SUM(x.reward) as total_reward_per_day \ from (SELECT hash, height, CAST(timestamp AS DATE), \ CASE \ - WHEN height <= 1440 THEN 200 \ - WHEN height <= 2880 THEN 180 \ - WHEN height <= 4320 THEN 160 \ - WHEN height <= 5760 THEN 140 \ - WHEN height <= 7200 THEN 120 \ - WHEN height <= 8640 THEN 100 \ - WHEN height <= 10080 THEN 80 \ - WHEN height <= 11520 THEN 60 \ - WHEN height <= 12960 THEN 50 \ - ELSE 25 \ + WHEN height <= '+BLOCK_ERA_1+' THEN 16 \ + WHEN height <= '+BLOCK_ERA_2+' THEN 8 \ + WHEN height <= '+BLOCK_ERA_3+' THEN 4 \ + WHEN height <= '+BLOCK_ERA_4+' THEN 2 \ + WHEN height <= '+BLOCK_ERA_5+' THEN 1 \ + ELSE '+BASE_REWARD_ERA_6_ONWARDS+' / (1 << ((height - ('+BLOCK_ERA_5+'- 1))/'+BLOCK_ERA_6_ONWARDS+'))\ END AS reward \ - FROM blockchain_block where ' + + FROM blockchain_block where height > 0 AND ' + timeIntervalQry + ') as x group by x.timestamp Order by x.timestamp ASC', ) @@ -1891,6 +1904,28 @@ let remaining_height = 0; next(err_msg); }); + + + /// Compute the total reward generated by each block in a given height. + // if (BlockchainBlockFetchQuery.Height <= BLOCK_ERA_1) { + // BlockchainBlockFetchQuery['BlockReward'] = 16; + // } else if (BlockchainBlockFetchQuery.Height <= BLOCK_ERA_2) { + // BlockchainBlockFetchQuery['BlockReward'] = 8; + // } else if (BlockchainBlockFetchQuery.Height <= BLOCK_ERA_3) { + // BlockchainBlockFetchQuery['BlockReward'] = 4; + // } else if (BlockchainBlockFetchQuery.Height <= BLOCK_ERA_4) { + // BlockchainBlockFetchQuery['BlockReward'] = 2; + // } else if (BlockchainBlockFetchQuery.Height <= BLOCK_ERA_5) { + // BlockchainBlockFetchQuery['BlockReward'] = 1; + // } else { + // // After the era 6, we reduce the block rewards by half each 1460 days. + // // Minus 1 to include multiples in the same index + // // (i.e changes greater than to greater or equals to) + // let height_with_offset = BlockchainBlockFetchQuery.Height - (BLOCK_ERA_5 - 1); + // let exp = height_with_offset / BLOCK_ERA_6_ONWARDS; + // BlockchainBlockFetchQuery['BlockReward'] = BASE_REWARD_ERA_6_ONWARDS / (1 << exp); + // } + let date = [], total_reward_per_day = [], addedreward = [], diff --git a/src/app/view/home/latestblocks/latestblocks.component.html b/src/app/view/home/latestblocks/latestblocks.component.html index a2b3c10..251b1be 100644 --- a/src/app/view/home/latestblocks/latestblocks.component.html +++ b/src/app/view/home/latestblocks/latestblocks.component.html @@ -163,9 +163,11 @@
-

Peers {{ +

Peers + {{ peers.length | number - }}

+ }}
+

diff --git a/src/app/view/home/latestblocks/latestblocks.component.ts b/src/app/view/home/latestblocks/latestblocks.component.ts index 73d4db2..8951c06 100644 --- a/src/app/view/home/latestblocks/latestblocks.component.ts +++ b/src/app/view/home/latestblocks/latestblocks.component.ts @@ -99,7 +99,11 @@ export class LatestblocksComponent implements OnInit { this.chartService.apiGetRequest('','/blockchain_kernel/getpeers').subscribe( res => { if (res['status'] == 200) { - this.peers = res.response.dataJson; + let json = res.response.dataJson; + if(json && json.length > 0){ + localStorage.setItem('peersJson',JSON.stringify(json)); + } + this.peers = JSON.parse(localStorage.getItem('peersJson')); } }, error => {}, From c0bab51ab2c4d7134247582128f420307d05040b Mon Sep 17 00:00:00 2001 From: SuriyaR Date: Tue, 13 Aug 2019 12:54:01 +0530 Subject: [PATCH 10/18] ISsue --- server/controllers/BlockchainBlock.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/server/controllers/BlockchainBlock.ts b/server/controllers/BlockchainBlock.ts index 77c23ce..69e52b5 100644 --- a/server/controllers/BlockchainBlock.ts +++ b/server/controllers/BlockchainBlock.ts @@ -1886,7 +1886,7 @@ let remaining_height = 0; const BASE_REWARD_ERA_6_ONWARDS = 0.15625; const BlockchainBlockPerSecondQuery = await getConnection() .query( - 'select x.timestamp, x.height, SUM(x.reward) as total_reward_per_day \ + 'select x.timestamp, SUM(x.reward) as total_reward_per_day \ from (SELECT hash, height, CAST(timestamp AS DATE), \ CASE \ WHEN height <= '+BLOCK_ERA_1+' THEN 16 \ From eadb90e8d59714b97da8d7c9d96f3f8c3c7ecaa2 Mon Sep 17 00:00:00 2001 From: SuriyaR Date: Tue, 13 Aug 2019 13:20:34 +0530 Subject: [PATCH 11/18] Supply growth error --- server/controllers/BlockchainBlock.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/server/controllers/BlockchainBlock.ts b/server/controllers/BlockchainBlock.ts index 69e52b5..1c0e71b 100644 --- a/server/controllers/BlockchainBlock.ts +++ b/server/controllers/BlockchainBlock.ts @@ -1887,7 +1887,7 @@ let remaining_height = 0; const BlockchainBlockPerSecondQuery = await getConnection() .query( 'select x.timestamp, SUM(x.reward) as total_reward_per_day \ - from (SELECT hash, height, CAST(timestamp AS DATE), \ + from (SELECT DISTINCT height, hash, CAST(timestamp AS DATE), \ CASE \ WHEN height <= '+BLOCK_ERA_1+' THEN 16 \ WHEN height <= '+BLOCK_ERA_2+' THEN 8 \ From b444da9e9f2b8e7f451a4117098fc7c4a8ec49e6 Mon Sep 17 00:00:00 2001 From: "raja.blaze" Date: Tue, 13 Aug 2019 16:07:53 +0530 Subject: [PATCH 12/18] Changes updated --- server/controllers/BlockchainBlock.ts | 112 +++++++++++++++----------- 1 file changed, 64 insertions(+), 48 deletions(-) diff --git a/server/controllers/BlockchainBlock.ts b/server/controllers/BlockchainBlock.ts index 69e52b5..fb10949 100644 --- a/server/controllers/BlockchainBlock.ts +++ b/server/controllers/BlockchainBlock.ts @@ -1235,54 +1235,70 @@ export class BlockchainBlockController { next(err_msg); }); } - let date = [], - DifficultyCuckatoo = [], - DifficultyProgpow = [], - DifficultyRandomx = []; + // let date = [], + // DifficultyCuckatoo = [], + // DifficultyProgpow = [], + // DifficultyRandomx = []; - TotalDifficultyNBlockQuery.forEach(e => { - date.push(moment(e.date).format(dateFormat)); - DifficultyCuckatoo.push(parseInt(e.total_difficulty_cuckatoo)); - DifficultyProgpow.push(parseInt(e.total_difficulty_progpow)); - DifficultyRandomx.push(parseInt(e.total_difficulty_randomx)); + var DifficultyCuckatoo = TotalDifficultyNBlockQuery.map(function (e) { + return parseInt(e.total_difficulty_cuckatoo); }); - var Maxrange; - var Minrange; - if(alog_type == "cuckatoo"){ - Maxrange = Math.max.apply(Math, TotalDifficultyNBlockQuery.map(function(o) { return o.total_difficulty_cuckatoo; })); - Minrange = Math.min.apply(Math, TotalDifficultyNBlockQuery.map(function(o) { return o.total_difficulty_cuckatoo; })); - if(Minrange != 0){ - Minrange = (Minrange - (Minrange * 0.2)); - } - Maxrange = (Maxrange + (Maxrange * 0.2)); - }else if(alog_type == "progpow"){ - Maxrange = Math.max.apply(Math, TotalDifficultyNBlockQuery.map(function(o) { return o.total_difficulty_progpow; })); - Minrange = Math.min.apply(Math, TotalDifficultyNBlockQuery.map(function(o) { return o.total_difficulty_progpow; })); - if(Minrange != 0){ - Minrange = (Minrange - (Minrange * 0.2)); - } - Maxrange = (Maxrange + (Maxrange * 0.2)); - }else if(alog_type == "randomx"){ - Maxrange = Math.max.apply(Math, TotalDifficultyNBlockQuery.map(function(o) { return o.total_difficulty_randomx; })); - Minrange = Math.min.apply(Math, TotalDifficultyNBlockQuery.map(function(o) { return o.total_difficulty_randomx; })); - if(Minrange != 0){ - Minrange = (Minrange - (Minrange * 0.2)); - } - Maxrange = (Maxrange + (Maxrange * 0.2)); - }else{ - var Maxrange1 = Math.max.apply(Math, TotalDifficultyNBlockQuery.map(function(o) { return o.total_difficulty_cuckatoo; })); - var Minrange1 = Math.min.apply(Math, TotalDifficultyNBlockQuery.map(function(o) { return o.total_difficulty_cuckatoo; })); - var Maxrange2 = Math.max.apply(Math, TotalDifficultyNBlockQuery.map(function(o) { return o.total_difficulty_progpow; })); - var Minrange2 = Math.min.apply(Math, TotalDifficultyNBlockQuery.map(function(o) { return o.total_difficulty_progpow; })); - var Maxrange3 = Math.max.apply(Math, TotalDifficultyNBlockQuery.map(function(o) { return o.total_difficulty_randomx; })); - var Minrange3 = Math.min.apply(Math, TotalDifficultyNBlockQuery.map(function(o) { return o.total_difficulty_randomx; })); - Maxrange = Math.max(Maxrange1, Maxrange2, Maxrange3); - Minrange = Math.min(Minrange1, Minrange2, Minrange3); - if(Minrange != 0){ - Minrange = (Minrange - (Minrange * 0.2)); - } - Maxrange = (Maxrange + (Maxrange * 0.2)); - } + + var DifficultyProgpow = TotalDifficultyNBlockQuery.map(function (e) { + return parseInt(e.total_difficulty_progpow); + }); + + var DifficultyRandomx = TotalDifficultyNBlockQuery.map(function (e) { + return parseInt(e.total_difficulty_randomx); + }); + + var date = TotalDifficultyNBlockQuery.map(function (e) { + return moment(e.date).format(dateFormat); + }); + + // TotalDifficultyNBlockQuery.forEach(e => { + // date.push(moment(e.date).format(dateFormat)); + // DifficultyCuckatoo.push(parseInt(e.total_difficulty_cuckatoo)); + // DifficultyProgpow.push(parseInt(e.total_difficulty_progpow)); + // DifficultyRandomx.push(parseInt(e.total_difficulty_randomx)); + // }); + // var Maxrange; + // var Minrange; + // if(alog_type == "cuckatoo"){ + // Maxrange = Math.max.apply(Math, DifficultyCuckatoo); + // Minrange = Math.min.apply(Math, DifficultyCuckatoo); + // if(Minrange != 0){ + // Minrange = (Minrange - (Minrange * 0.2)); + // } + // Maxrange = (Maxrange + (Maxrange * 0.2)); + // }else if(alog_type == "progpow"){ + // Maxrange = Math.max.apply(Math, DifficultyProgpow); + // Minrange = Math.min.apply(Math, DifficultyProgpow); + // if(Minrange != 0){ + // Minrange = (Minrange - (Minrange * 0.2)); + // } + // Maxrange = (Maxrange + (Maxrange * 0.2)); + // }else if(alog_type == "randomx"){ + // Maxrange = Math.max.apply(Math, DifficultyRandomx); + // Minrange = Math.min.apply(Math, DifficultyRandomx); + // if(Minrange != 0){ + // Minrange = (Minrange - (Minrange * 0.2)); + // } + // Maxrange = (Maxrange + (Maxrange * 0.2)); + // }else{ + // var Maxrange1 = Math.max.apply(Math, TotalDifficultyNBlockQuery.map(function(o) { return o.total_difficulty_cuckatoo; })); + // var Minrange1 = Math.min.apply(Math, TotalDifficultyNBlockQuery.map(function(o) { return o.total_difficulty_cuckatoo; })); + // var Maxrange2 = Math.max.apply(Math, TotalDifficultyNBlockQuery.map(function(o) { return o.total_difficulty_progpow; })); + // var Minrange2 = Math.min.apply(Math, TotalDifficultyNBlockQuery.map(function(o) { return o.total_difficulty_progpow; })); + // var Maxrange3 = Math.max.apply(Math, TotalDifficultyNBlockQuery.map(function(o) { return o.total_difficulty_randomx; })); + // var Minrange3 = Math.min.apply(Math, TotalDifficultyNBlockQuery.map(function(o) { return o.total_difficulty_randomx; })); + // Maxrange = Math.max(Maxrange1, Maxrange2, Maxrange3); + // Minrange = Math.min(Minrange1, Minrange2, Minrange3); + // if(Minrange != 0){ + // Minrange = (Minrange - (Minrange * 0.2)); + // } + // Maxrange = (Maxrange + (Maxrange * 0.2)); + // } // Minrange = parseInt(Minrange); // var Minrange2 = parseInt(Minrange * 0.3); @@ -1295,8 +1311,8 @@ export class BlockchainBlockController { DifficultyCuckatoo: DifficultyCuckatoo, DifficultyRandomx: DifficultyRandomx, DifficultyProgpow: DifficultyProgpow, - Maxrange: Maxrange, - Minrange: Minrange, + //Maxrange: Maxrange, + //Minrange: Minrange, tickFormat: tickFormat }, }); From 57b8a76c6414e44fd3add9e7a6d40c7a4d61f847 Mon Sep 17 00:00:00 2001 From: SuriyaR Date: Tue, 13 Aug 2019 16:09:02 +0530 Subject: [PATCH 13/18] Multiple y axis --- .../graph-detail/graph-detail.component.html | 4 +- .../home/graph-list/graph-list.component.html | 12 +- .../home/graph-list/graph-list.component.ts | 318 ++++++++++-------- 3 files changed, 187 insertions(+), 147 deletions(-) diff --git a/src/app/view/graph-view/graph-detail/graph-detail.component.html b/src/app/view/graph-view/graph-detail/graph-detail.component.html index ffd3909..60a1e08 100644 --- a/src/app/view/graph-view/graph-detail/graph-detail.component.html +++ b/src/app/view/graph-view/graph-detail/graph-detail.component.html @@ -67,7 +67,7 @@

{{chartType | translate}}

-
+
diff --git a/src/app/view/home/graph-list/graph-list.component.html b/src/app/view/home/graph-list/graph-list.component.html index cae6cc1..81e76ac 100644 --- a/src/app/view/home/graph-list/graph-list.component.html +++ b/src/app/view/home/graph-list/graph-list.component.html @@ -8,7 +8,7 @@ }} -->
-
+ @@ -43,7 +43,7 @@
-
+
1 day @@ -530,7 +530,7 @@ }} -->
-
+
-
+
1 day diff --git a/src/app/view/home/graph-list/graph-list.component.ts b/src/app/view/home/graph-list/graph-list.component.ts index 2c0a9d0..ed568c5 100644 --- a/src/app/view/home/graph-list/graph-list.component.ts +++ b/src/app/view/home/graph-list/graph-list.component.ts @@ -65,8 +65,8 @@ export class GraphListComponent implements OnInit { viewchartvar: boolean; - constructor(private chartService: ChartService, private http: HttpClient,public translate: TransServiceService, private router: Router, - ) { + constructor(private chartService: ChartService, private http: HttpClient, public translate: TransServiceService, private router: Router, + ) { if (this.router.url == '/all') { this.viewchartvar = true; } else { @@ -126,16 +126,16 @@ export class GraphListComponent implements OnInit { if (res['status'] == 200) { let plabel = res.response.label; let pvalues = res.response.value; - this.pg_last = - pvalues[pvalues.length - 1]; - this.piechartFunc( - plabel, - pvalues, - ); + this.pg_last = + pvalues[pvalues.length - 1]; + this.piechartFunc( + plabel, + pvalues, + ); resolve(); } }, - error => {}, + error => { }, ); }); } @@ -159,18 +159,18 @@ export class GraphListComponent implements OnInit { let Cuckoo = res.response.Cuckoo; let ProgPow = res.response.ProgPow; let RandomX = res.response.RandomX; - this.sg_last = + this.sg_last = RandomX[RandomX.length - 1]; - this.stackchartFunc( - sDate, - Cuckoo, - ProgPow, - RandomX - ); + this.stackchartFunc( + sDate, + Cuckoo, + ProgPow, + RandomX + ); resolve(); } }, - error => {}, + error => { }, ); }); } @@ -224,7 +224,7 @@ export class GraphListComponent implements OnInit { resolve(); } }, - error => {}, + error => { }, ); }); } @@ -266,7 +266,7 @@ export class GraphListComponent implements OnInit { resolve(); } }, - error => {}, + error => { }, ); }); } @@ -304,7 +304,7 @@ export class GraphListComponent implements OnInit { resolve(); } }, - error => {}, + error => { }, ); }); } @@ -327,7 +327,7 @@ export class GraphListComponent implements OnInit { resolve(); } }, - error => {}, + error => { }, ); }); } @@ -351,7 +351,7 @@ export class GraphListComponent implements OnInit { resolve(); } }, - error => {}, + error => { }, ); }); } @@ -374,7 +374,7 @@ export class GraphListComponent implements OnInit { resolve(); } }, - error => {}, + error => { }, ); }); } @@ -400,49 +400,51 @@ export class GraphListComponent implements OnInit { res => { if (res['status'] == 200) { let DifficultychartDate = res.response.Date; - let DifficultyCuckatoo = res.response.DifficultyCuckatoo; + let DifficultyCuckatoo = res.response.DifficultyCuckatoo; let DifficultyRandomx = res.response.DifficultyRandomx; let DifficultyProgpow = res.response.DifficultyProgpow; let data; - switch(this.Type) { + switch (this.Type) { case 'all': - data = + data = [ { x: DifficultychartDate, y: DifficultyCuckatoo, text: DifficultychartDate, - mode: 'lines+markers', + // mode: 'lines+markers', type: 'scatter', name: '', - line: { color: '#ac3333' }, + // line: { color: '#ac3333' }, hovertemplate: '%{text}
Cuckoo : %{y:,}', }, { x: DifficultychartDate, y: DifficultyProgpow, text: DifficultychartDate, - mode: 'lines+markers', + // mode: 'lines+markers', type: 'scatter', name: '', - line: { color: '#ac3333' }, + yaxis: 'y2', + // line: { color: '#ac3333' }, hovertemplate: '%{text}
Progpow : %{y:,}', }, { x: DifficultychartDate, y: DifficultyRandomx, text: DifficultychartDate, - mode: 'lines+markers', + // mode: 'lines+markers', type: 'scatter', name: '', - line: { color: '#ac3333' }, + yaxis: 'y3', + // line: { color: '#ac3333' }, hovertemplate: '%{text}
RandomX : %{y:,}', }, ]; - break; + break; default: - let yvalue = this.Type == 'cuckatoo' ? DifficultyCuckatoo : this.Type == 'progpow' ? DifficultyProgpow : this.Type == 'randomx' ? DifficultyRandomx : [] - data = + let yvalue = this.Type == 'cuckatoo' ? DifficultyCuckatoo : this.Type == 'progpow' ? DifficultyProgpow : this.Type == 'randomx' ? DifficultyRandomx : [] + data = [ { x: DifficultychartDate, @@ -454,38 +456,38 @@ export class GraphListComponent implements OnInit { line: { color: '#ac3333' }, hovertemplate: '%{text}
Difficulty : %{y:,}', }]; - break; - } + break; + } - let range = [res.response.Minrange, res.response.Maxrange] - let tickformat = res.response.tickFormat; - // this.lg_last = - // TargetDifficulty[TargetDifficulty.length - 1]; + let range = [res.response.Minrange, res.response.Maxrange] + let tickformat = res.response.tickFormat; + // this.lg_last = + // TargetDifficulty[TargetDifficulty.length - 1]; - switch(difftype){ - case 'total': - this.totaldifficultyChartFunc( - DifficultychartDate, - data, - this.Type, - range, - tickformat - ); - break; - case 'target': - this.difficultyChartFunc( - DifficultychartDate, - data, - this.Type, - range, - tickformat - ); - break; - } + switch (difftype) { + case 'total': + this.totaldifficultyChartFunc( + DifficultychartDate, + data, + this.Type, + range, + tickformat + ); + break; + case 'target': + this.difficultyChartFunc( + DifficultychartDate, + data, + this.Type, + range, + tickformat + ); + break; + } resolve(); } }, - error => {}, + error => { }, ); }); } @@ -507,13 +509,13 @@ export class GraphListComponent implements OnInit { if (res['status'] == 200) { let DifficultychartDate = res.response.Date; let BlocksChartDate = res.response.blockDate; - let Blockval = res.response.Blocks; - this.brg_last = Blockval[Blockval.length - 1]; - this.totalBlocksFunc(BlocksChartDate, Blockval); + let Blockval = res.response.Blocks; + this.brg_last = Blockval[Blockval.length - 1]; + this.totalBlocksFunc(BlocksChartDate, Blockval); resolve(); } }, - error => {}, + error => { }, ); }); } @@ -521,23 +523,42 @@ export class GraphListComponent implements OnInit { difficultyChartFunc(DifficultychartDate, data, Type, range, tickformat) { // console.log('range rangerangerange',range); this.linearGraphData = { - data: data , + data: data, layout: { - hovermode: 'closest', + // hovermode: 'closest', height: 250, autosize: true, showlegend: false, xaxis: { tickangle: -45, tickformat: tickformat, - showgrid: true, - fixedrange: true + fixedrange: true, + // showgrid: true }, yaxis: { - title: 'Diff', - showgrid: true, + title: 'Cuckoo', fixedrange: true, - range: range + // showgrid: true, + // range: range + }, + yaxis2: { + title: 'Progpow', + fixedrange: true, + // showgrid: true, + // range: range, + overlaying: 'y', + side: 'left', + position: 0.25 + }, + yaxis3: { + title: 'RandomX', + fixedrange: true, + // showgrid: true, + // range: range, + anchor: 'x', + overlaying: 'y', + side: 'right' + }, margin: { l: 50, @@ -633,7 +654,7 @@ export class GraphListComponent implements OnInit { piechartFunc(plabel, pvalues) { - this.pieGraphData = { + this.pieGraphData = { data: [ { values: pvalues, @@ -648,7 +669,7 @@ export class GraphListComponent implements OnInit { height: 250, autosize: false, showlegend: false, - xaxis: { + xaxis: { tickangle: -45, tickformat: '%m-%d', showgrid: true, @@ -822,7 +843,7 @@ export class GraphListComponent implements OnInit { ], layout: { hovermode: 'closest', - // width: 350, + // width: 350, height: 250, autosize: true, xaxis: { @@ -849,7 +870,7 @@ export class GraphListComponent implements OnInit { }; } - blockminedFunc(mDate,ProgPow, Cuckoo, RandomX, ProgPowper, Cuckooper, RandomXper) { + blockminedFunc(mDate, ProgPow, Cuckoo, RandomX, ProgPowper, Cuckooper, RandomXper) { this.doubleareaGraphData = { data: [ { @@ -932,64 +953,64 @@ export class GraphListComponent implements OnInit { transactionheatmapFunc(tDate, tHour, tInput, hovertext) { return new Promise((resolve, reject) => { - this.heatMapGrowthData = { - data: [ - { - x: tHour, - y: tDate, - z: tInput, - name: '', - text: hovertext, - hovertemplate: hovertext + ': %{z:,} ', - colorscale: 'Rainbow', - type: 'heatmap', - visible: true, - colorbar: { thickness: 3 }, - xgap: 1, - ygap: 1, - }, - ], - layout: { - hovermode: 'closest', - height: 250, - //width: 365, - autosize: true, - annotations: [], - font: { - size: 8.5, - }, - xaxis: { - ticks: '', - tickangle: screen.width < 767 ? '-90' : 360, - side: 'top', - autotick: false, - showgrid: true, - rangemode: 'nonnegative', - fixedrange: true, + this.heatMapGrowthData = { + data: [ + { + x: tHour, + y: tDate, + z: tInput, + name: '', + text: hovertext, + hovertemplate: hovertext + ': %{z:,} ', + colorscale: 'Rainbow', + type: 'heatmap', + visible: true, + colorbar: { thickness: 3 }, + xgap: 1, + ygap: 1, + }, + ], + layout: { + hovermode: 'closest', + height: 250, + //width: 365, autosize: true, + annotations: [], + font: { + size: 8.5, + }, + xaxis: { + ticks: '', + tickangle: screen.width < 767 ? '-90' : 360, + side: 'top', + autotick: false, + showgrid: true, + rangemode: 'nonnegative', + fixedrange: true, + autosize: true, + }, + yaxis: { + ticks: '', + ticksuffix: ' ', + tickformat: '%m-%d', + autosize: true, + showgrid: true, + autotick: false, + rangemode: 'nonnegative', + fixedrange: true, + }, + margin: { + l: 30, + r: 0, + b: 50, + t: 50, + }, + showlegend: false, }, - yaxis: { - ticks: '', - ticksuffix: ' ', - tickformat: '%m-%d', - autosize: true, - showgrid: true, - autotick: false, - rangemode: 'nonnegative', - fixedrange: true, - }, - margin: { - l: 30, - r: 0, - b: 50, - t: 50, - }, - showlegend: false, - }, - options: null, - }; - resolve(); - }); + options: null, + }; + resolve(); + }); } transactionlinechartFunc(Tdate, Ttotalinput, Ttotalkernal, Ttotaloutput) { this.feeGraphData = { @@ -1027,7 +1048,7 @@ export class GraphListComponent implements OnInit { ], layout: { autosize: true, - // width: 350, + // width: 350, height: 250, xaxis: { showgrid: true, @@ -1109,7 +1130,7 @@ export class GraphListComponent implements OnInit { this.linearTotalGraphData = { data: data, layout: { - hovermode: 'closest', + // hovermode: 'closest', height: 250, autosize: true, showlegend: false, @@ -1117,13 +1138,32 @@ export class GraphListComponent implements OnInit { tickangle: -45, tickformat: tickformat, fixedrange: true, - showgrid: true + // showgrid: true }, yaxis: { - title: 'Diff', + title: 'Cuckoo', fixedrange: true, - showgrid: true, - range: range + // showgrid: true, + // range: range + }, + yaxis2: { + title: 'Progpow', + fixedrange: true, + // showgrid: true, + // range: range, + overlaying: 'y', + side: 'left', + position: 0.25 + }, + yaxis3: { + title: 'RandomX', + fixedrange: true, + // showgrid: true, + // range: range, + anchor: 'x', + overlaying: 'y', + side: 'right' + }, margin: { l: 50, From b70ed375a9fea4629a43042729f4107f1c596fa9 Mon Sep 17 00:00:00 2001 From: SuriyaR Date: Tue, 13 Aug 2019 16:10:34 +0530 Subject: [PATCH 14/18] Remove the range --- src/app/view/home/graph-list/graph-list.component.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/app/view/home/graph-list/graph-list.component.ts b/src/app/view/home/graph-list/graph-list.component.ts index ed568c5..ccce9d0 100644 --- a/src/app/view/home/graph-list/graph-list.component.ts +++ b/src/app/view/home/graph-list/graph-list.component.ts @@ -458,8 +458,8 @@ export class GraphListComponent implements OnInit { }]; break; } - - let range = [res.response.Minrange, res.response.Maxrange] + // res.response.Minrange, res.response.Maxrange + let range = []; let tickformat = res.response.tickFormat; // this.lg_last = // TargetDifficulty[TargetDifficulty.length - 1]; From f44a25ccc02af7248bdc9062ef8e5eb1f1c47eb9 Mon Sep 17 00:00:00 2001 From: root Date: Tue, 13 Aug 2019 16:49:10 +0530 Subject: [PATCH 15/18] Floonet added --- .../components/header/header.component.html | 21 ++++++++++--------- .../siteheader/siteheader.component.html | 12 +++++++---- 2 files changed, 19 insertions(+), 14 deletions(-) diff --git a/src/app/shared/components/header/header.component.html b/src/app/shared/components/header/header.component.html index c664e5a..1b02ff1 100755 --- a/src/app/shared/components/header/header.component.html +++ b/src/app/shared/components/header/header.component.html @@ -20,19 +20,20 @@
diff --git a/src/app/shared/components/siteheader/siteheader.component.html b/src/app/shared/components/siteheader/siteheader.component.html index b8a3122..3885163 100644 --- a/src/app/shared/components/siteheader/siteheader.component.html +++ b/src/app/shared/components/siteheader/siteheader.component.html @@ -13,10 +13,12 @@ + @@ -64,10 +66,12 @@ + From 15dcd6b30dcdc7ef69eaab9c7736c9600376140a Mon Sep 17 00:00:00 2001 From: root Date: Tue, 13 Aug 2019 16:54:28 +0530 Subject: [PATCH 16/18] Floonet added --- server/controllers/BlockchainKernel.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/server/controllers/BlockchainKernel.ts b/server/controllers/BlockchainKernel.ts index 71cfcc0..3c80927 100644 --- a/server/controllers/BlockchainKernel.ts +++ b/server/controllers/BlockchainKernel.ts @@ -516,7 +516,7 @@ export class BlockchainKernelController { ) => { var self = this; try { - http.get('http://116.203.152.58:3413/v1/peers/connected', + http.get('http://116.203.152.58:13413/v1/peers/connected', async (resp) => { // console.log('resp resp respresp',resp); let data = ''; From a08290763d29070b28a351fe4e4d656a14ba5234 Mon Sep 17 00:00:00 2001 From: SuriyaR Date: Tue, 13 Aug 2019 19:24:35 +0530 Subject: [PATCH 17/18] Multiple axis ui issue fixed --- .../graph-view/graph-detail/graph-detail.component.ts | 8 ++++++++ src/app/view/home/graph-list/graph-list.component.ts | 6 ++++-- 2 files changed, 12 insertions(+), 2 deletions(-) diff --git a/src/app/view/graph-view/graph-detail/graph-detail.component.ts b/src/app/view/graph-view/graph-detail/graph-detail.component.ts index 6c2702b..1789de9 100644 --- a/src/app/view/graph-view/graph-detail/graph-detail.component.ts +++ b/src/app/view/graph-view/graph-detail/graph-detail.component.ts @@ -60,6 +60,8 @@ export class GraphDetailComponent implements OnInit { this.hashdata = this.comp.linearTotalGraphData; console.log('this.comp.linearTotalGraphData',this.comp.linearTotalGraphData); this.hashdata.layout.height = 300; + this.hashdata.layout.xaxis.domain = [0.1,0.9]; + this.hashdata.layout.yaxis2.position = 2.25; this.title = 'Total Difficulty'; this.selectedItem = 6; this.titleService.setTitle( @@ -74,6 +76,8 @@ export class GraphDetailComponent implements OnInit { this.hashdata = this.comp.linearGraphData; console.log('this.comp.linearGraphData',this.comp.linearGraphData); this.hashdata.layout.height = 300; + this.hashdata.layout.xaxis.domain = [0.1,0.9]; + this.hashdata.layout.yaxis2.position = 2.25; this.title = 'Target Difficulty'; this.selectedItem = 6; this.titleService.setTitle( @@ -222,6 +226,8 @@ export class GraphDetailComponent implements OnInit { this.comp.Difficultyreq('target',p1, p2, p3, p4).then(res => { this.hashdata = this.comp.linearGraphData; this.hashdata.layout.height = 300; + this.hashdata.layout.xaxis.domain = [0.1,0.9]; + this.hashdata.layout.yaxis2.position = 2.25; this.title = 'Target Difficulty'; }); break; @@ -229,6 +235,8 @@ export class GraphDetailComponent implements OnInit { this.comp.Difficultyreq('total',p1, p2, p3, p4).then(res => { this.hashdata = this.comp.linearTotalGraphData; this.hashdata.layout.height = 300; + this.hashdata.layout.xaxis.domain = [0.1,0.9]; + this.hashdata.layout.yaxis2.position = 2.25; this.title = 'Total Difficulty'; }); break; diff --git a/src/app/view/home/graph-list/graph-list.component.ts b/src/app/view/home/graph-list/graph-list.component.ts index ccce9d0..1d0cb2b 100644 --- a/src/app/view/home/graph-list/graph-list.component.ts +++ b/src/app/view/home/graph-list/graph-list.component.ts @@ -533,6 +533,7 @@ export class GraphListComponent implements OnInit { tickangle: -45, tickformat: tickformat, fixedrange: true, + domain: [0.2, 0.8] // showgrid: true }, yaxis: { @@ -548,7 +549,7 @@ export class GraphListComponent implements OnInit { // range: range, overlaying: 'y', side: 'left', - position: 0.25 + position: 1.25 }, yaxis3: { title: 'RandomX', @@ -1138,6 +1139,7 @@ export class GraphListComponent implements OnInit { tickangle: -45, tickformat: tickformat, fixedrange: true, + domain: [0.2, 0.8] // showgrid: true }, yaxis: { @@ -1153,7 +1155,7 @@ export class GraphListComponent implements OnInit { // range: range, overlaying: 'y', side: 'left', - position: 0.25 + position: 1.25 }, yaxis3: { title: 'RandomX', From c5897da2f8efb9bc6accfc9c908637b775086075 Mon Sep 17 00:00:00 2001 From: SuriyaR Date: Wed, 14 Aug 2019 11:07:34 +0530 Subject: [PATCH 18/18] Graph place changes --- .../graph-detail/graph-detail.component.html | 8 +- .../home/graph-list/graph-list.component.html | 212 +++++++++--------- 2 files changed, 110 insertions(+), 110 deletions(-) diff --git a/src/app/view/graph-view/graph-detail/graph-detail.component.html b/src/app/view/graph-view/graph-detail/graph-detail.component.html index 60a1e08..9b59282 100644 --- a/src/app/view/graph-view/graph-detail/graph-detail.component.html +++ b/src/app/view/graph-view/graph-detail/graph-detail.component.html @@ -157,8 +157,8 @@ diff --git a/src/app/view/home/graph-list/graph-list.component.html b/src/app/view/home/graph-list/graph-list.component.html index 81e76ac..c6c8194 100644 --- a/src/app/view/home/graph-list/graph-list.component.html +++ b/src/app/view/home/graph-list/graph-list.component.html @@ -1,81 +1,71 @@