Modifications

This commit is contained in:
shunmugam 2020-01-08 14:50:39 +05:30
parent ec64f14b42
commit 5fc90e7d91

View File

@ -375,25 +375,28 @@ async function avgBlockTime(height) {
const blockaveragetime = await getConnection(Global.network) const blockaveragetime = await getConnection(Global.network)
.query( .query(
'SELECT coalesce(avg(bb.alter), 0) as alter 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', 'SELECT coalesce(avg(bb.alter), 0) as alter FROM (SELECT EXTRACT(EPOCH FROM (timestamp - LAG(timestamp) OVER (ORDER BY timestamp))) AS alter FROM blockchain_block where height > '+(height - 1440)+' AND height < '+height+' ) as bb',
) )
.catch(err_msg => { .catch(err_msg => {
return(err_msg); return(err_msg);
}); });
return blockaveragetime['alter']
console.log("_________________________________");
console.log("Block Average time is ",blockaveragetime)
} }
async function network_hashrate(height, edge_bits, difficulty) { async function network_hashrate(height, edge_bits, difficulty) {
let graph_wight = await avgBlockTime(height)
return (difficulty / graph_wight);
}
async function network_hashrate_old(height, edge_bits, difficulty) {
let graph_wight = await graph_weight(height, edge_bits) let graph_wight = await graph_weight(height, edge_bits)
return (42.0 * (difficulty / graph_wight) / 60.0); return (42.0 * (difficulty / graph_wight) / 60.0);
} }
async function graph_weight(height, edge_bits) { async function graph_weight(height, edge_bits) {
let xpr_edge_bits = edge_bits; let xpr_edge_bits = edge_bits;