Commit for avg block time testing

This commit is contained in:
shunmugam 2020-01-13 13:32:25 +05:30
parent e253971e26
commit a9de2c2267
2 changed files with 29 additions and 4 deletions

View File

@ -89,7 +89,7 @@
}, },
"api-view": { "api-view": {
"query-api" : "Query API", "query-api" : "Query API",
"maxcoins" : "Return maximum supply", "maxcoins" : "returns maximum supply",
"query-api-line1" : "The API function to call is specified through the q parameter.", "query-api-line1" : "The API function to call is specified through the q parameter.",
"query-api-line2" : "For instance you can ask the totalcoins of epic cash with ", "query-api-line2" : "For instance you can ask the totalcoins of epic cash with ",
"circulating" : "returns the number of circulating coins", "circulating" : "returns the number of circulating coins",

View File

@ -463,12 +463,21 @@ let currentReward = 16;
progpowhashrate = Math.round(progpowhashrate) progpowhashrate = Math.round(progpowhashrate)
randomxhashrate = Math.round(randomxhashrate) randomxhashrate = Math.round(randomxhashrate)
// Test purpose
let test_cuckoo = await testavgBlockTime(block_height,"Cuckoo")
let test_randomx = await testavgBlockTime(block_height,"RandomX")
let test_progpow = await testavgBlockTime(block_height,"ProgPow")
console.log("-----------------")
console.log("Cuckoo avg block time ", test_cuckoo)
console.log("randomx avg block time ", test_randomx)
console.log("Progpow avg block time ", test_progpow)
// Total foundation reward // Total foundation reward
let totalFoundationReward = await circulationsupply(height) let totalFoundationReward = await circulationsupply(height)
console.log("-----------------------------------------------------------------------")
console.log("Function is calling")
return { return {
block_height, block_height,
letest_block, letest_block,
@ -552,6 +561,22 @@ const averageblockdifficulty = async() => {
async function testavgBlockTime(height,proof) {
// let query1 = "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"
let query1 = "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+" and proof = '"+proof+"' ) as bb"
const blockaveragetime = await getConnection(Global.network)
.query(
query1,
)
.catch(err_msg => {
return(err_msg);
});
return blockaveragetime[0]['alter']
}
async function avgBlockTime(height,proof) { async function avgBlockTime(height,proof) {