Skip to content

Instantly share code, notes, and snippets.

@mohamedmansour
Last active July 28, 2021 03:26
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mohamedmansour/183260a0f53a20d2eea5b0db6cb150a9 to your computer and use it in GitHub Desktop.
Save mohamedmansour/183260a0f53a20d2eea5b0db6cb150a9 to your computer and use it in GitHub Desktop.
Geth Sync Status
//
// 8% ETA: 53 minutes @ 1477.9bps
// 9% ETA: 27 minutes @ 2918.6bps
// 9% ETA: 34 minutes @ 2323.4bps
// 10% ETA: 34 minutes @ 2304.8bps
// 10% ETA: 37 minutes @ 2149.6bps
// 11% ETA: 36 minutes @ 2186bps
// 11% ETA: 35 minutes @ 2268bps
// 12% ETA: 30 minutes @ 2630.4bps
//
// To get the following console statements printed in geth, attach to your geth console (geth attach) and copy paste the codeblock below.
//
// START COPY --------------------
var lastPercentage = 0;
var lastBlocksToGo = 0;
var timeInterval = 10000;
function pollMonitor() {
var percentage = eth.syncing.currentBlock / eth.syncing.highestBlock * 100;
var percentagePerTime = percentage - lastPercentage;
var blocksToGo = eth.syncing.highestBlock - eth.syncing.currentBlock;
var bps = (lastBlocksToGo - blocksToGo) / (timeInterval / 1000)
var etas = 100 / percentagePerTime * (timeInterval / 1000)
var etaM = parseInt(etas / 60, 10);
if (etaM > 0) {
console.log(parseInt(percentage, 10) + '% ETA: '+ etaM + ' minutes @ '+ bps + 'bps, PEERCOUNT: ' + net.peerCount);
} else {
console.log(parseInt(percentage, 10) + '% PEERCOUNT: ' + net.peerCount + ', Starting monitor, polling every 10 sec...');
}
lastPercentage = percentage;
lastBlocksToGo = blocksToGo;
return true
}
function run() {
pollMonitor();
setInterval(pollMonitor, timeInterval);
}
run()
// END COPY --------------------
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment