diff --git a/server.ts b/server.ts index 7c4ebd1..c731770 100644 --- a/server.ts +++ b/server.ts @@ -142,6 +142,8 @@ try { result = Number(blockDetails.TotalDifficultyProgpow); else if(option == "totalcoins") result = 21000000 * 100000000; + else if(option == "maxcoins") + result = 21000000; else if(option == "average-blocktime") { let data = await averageblockdifficulty(); diff --git a/server/utils/common.ts b/server/utils/common.ts index e6f8ddc..0a0b556 100644 --- a/server/utils/common.ts +++ b/server/utils/common.ts @@ -287,7 +287,7 @@ let currentReward = 16; let cuckoohashrate = await network_hashrate(block_height,31,targetdifficultycuckatoo); let progpowhashrate = await network_hashrate(block_height,16,targetdifficultyprogpow); let randomxhashrate = await network_hashrate(block_height,16,targetdifficultyrandomx); - + let test = await avgBlockTime(block_height) return { block_height, letest_block, @@ -371,6 +371,21 @@ const averageblockdifficulty = async() => { +async function avgBlockTime(height) { + + const blockaveragetime = await getConnection(Global.network) + .query( + 'SELECT coalesce(avg(bb.alter), 0) as alter, bb.timestamp FROM (SELECT EXTRACT(EPOCH FROM (timestamp - LAG(timestamp) OVER (ORDER BY timestamp))) AS alter FROM blockchain_block where height < 1145 AND height > 2154 ) as bb', + ) + .catch(err_msg => { + return(err_msg); + }); + + console.log("_________________________________"); + console.log("Block Average time is ",blockaveragetime) +} + + async function network_hashrate(height, edge_bits, difficulty) { let graph_wight = await graph_weight(height, edge_bits) return (42.0 * (difficulty / graph_wight) / 60.0); diff --git a/src/app/view/api-view/api-view.component.html b/src/app/view/api-view/api-view.component.html index 7594dc3..e72eac6 100644 --- a/src/app/view/api-view/api-view.component.html +++ b/src/app/view/api-view/api-view.component.html @@ -31,6 +31,6 @@