Lisk Core Migration Block Height

node v8.16.2
version: 1.0.0
endpointsharetweet
const moment = require('moment-timezone'); const request = require('request') const rp = require('request-promise'); const currentHeight = JSON.parse(await rp('https://node01.lisk.io/api/loader/status/sync')).height; const currentTime = moment.tz('Europe/Berlin'); const calculateBlockByTime = (time) => { const expectedTimeOfRelease = moment.tz(time, 'Europe/Berlin'); const secondsRemaining = expectedTimeOfRelease.diff(currentTime, 'seconds'); const blocksRemaining = Math.floor(secondsRemaining / 10); const approxHeight = currentHeight + blocksRemaining; const expectedRound = Math.ceil(approxHeight / 101); const finalHeight = expectedRound * 101; console.log(`Height: ${finalHeight}`); console.log(`Round: ${expectedRound}`); return finalHeight; }; const calculateTimeByBlock = (finalHeight, estimatedMissedBlocksPerRound) => { const blocksRemaining = finalHeight - currentHeight; const expectedMissedBlocks = (blocksRemaining / 101) * estimatedMissedBlocksPerRound; const realSecondsRemaining = (blocksRemaining + expectedMissedBlocks) * 10; const currentTimestamp = currentTime.unix(); const resultTimestamp = currentTimestamp + realSecondsRemaining; console.log(`If ${estimatedMissedBlocksPerRound} blocks are missed every round:`); console.log(new Date(resultTimestamp*1000)); } const finalHeight = calculateBlockByTime('2018-08-29 11:00:00'); // Ideal scenario calculateTimeByBlock(finalHeight, 0); // Mean factor for 0.9.16 calculateTimeByBlock(finalHeight, 0.16); // Mean factor for the last month calculateTimeByBlock(finalHeight, 0.26); // Further estimations calculateTimeByBlock(finalHeight, 1); calculateTimeByBlock(finalHeight, 2); calculateTimeByBlock(finalHeight, 3); calculateTimeByBlock(finalHeight, 4); calculateTimeByBlock(finalHeight, 5);
Loading…

no comments

    sign in to comment