Last active
August 29, 2015 14:26
-
-
Save nand2/0ecf1db2fb7da8eeb706 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function computeRemainingTime(ratio_updated) { | |
var averageBlockTime = 12; | |
var blockGasIncrease = (20-3)/2; // Gross average of gas increase | |
var requiredGasLimit = 21000; | |
var currentGasLimit = eth.getBlock("latest").gasLimit; | |
var GasLimitDelta = requiredGasLimit - currentGasLimit; | |
var increasingBlockRatio = (ratio_updated - (1 - ratio_updated)); | |
var necessaryBlocks = (GasLimitDelta / increasingBlockRatio) / blockGasIncrease; | |
var necessaryTime = necessaryBlocks * averageBlockTime; | |
console.log("ETA for first TX: " + Math.round(necessaryTime / 3600) + "h" + Math.round((necessaryTime % 3600) / 60) + "m"); | |
} | |
function getUpdatedMinerRatio(){ | |
var latestBlock = eth.getBlock("latest"); | |
var n = latestBlock.number; | |
var gasLimit = []; | |
for (i = n-150; i<n; i++){ | |
var l = eth.getBlock(i).gasLimit; | |
gasLimit.push(l); | |
} | |
var updatedCount = 0; | |
var notUpdatedCount = 0; | |
gasLimit.forEach(function(e, i){ | |
if(i >= 1) { | |
if(e > gasLimit[i-1]) { | |
updatedCount++; | |
} | |
else { | |
notUpdatedCount++; | |
} | |
} | |
}); | |
var ratio_updated = updatedCount / (updatedCount + notUpdatedCount); | |
console.log("Current Block Number: " + n + "\nMiners updated to 1.0.1+ : " + Math.round(ratio_updated * 10000)/100 + "%" ); | |
console.log("Current gas limit: " + latestBlock.gasLimit); | |
if(ratio_updated < 0.5) { | |
console.log("Not enough switched miners yet for first tx ETA.") | |
} | |
else { | |
computeRemainingTime(ratio_updated); | |
} | |
var updated_ratios = [ 55, 60, 65, 70, 75, 80, 85, 90, 95, 100 ]; | |
updated_ratios.forEach(function(e) { | |
console.log("For info: if " + e + "% are updated"); | |
computeRemainingTime(e/100); | |
}); | |
} | |
getUpdatedMinerRatio(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment