Skip to content

Commit

Permalink
Add full sync estimate when loading data
Browse files Browse the repository at this point in the history
  • Loading branch information
vgrichina committed Jan 13, 2024
1 parent b12f263 commit f478be2
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions scripts/load-from-near-lake.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,13 @@ let timeStarted = Date.now();
async function handleStreamerMessage(streamerMessage, options = {}) {
const { height: blockHeight, timestamp } = streamerMessage.block.header;
totalMessages++;
const speed = totalMessages * 1000 / (Date.now() - timeStarted);
const lagSeconds = (Date.now() - (timestamp / 1000000)) / 1000;
const estimatedSyncSeconds = lagSeconds / speed;
console.log(new Date(), `Block #${blockHeight} Shards: ${streamerMessage.shards.length}`,
`Speed: ${totalMessages * 1000 / (Date.now() - timeStarted)} blocks/second`,
`Lag: ${Date.now() - (timestamp / 1000000)} ms`);
`Speed: ${speed.toFixed(2)} blocks/second`,
`Lag: ${lagSeconds.toFixed(2)} seconds`,
`Fully synced in: ${estimatedSyncSeconds.toFixed(2)} seconds`);

const pipeline = [
dumpBlockReceipts,
Expand Down

0 comments on commit f478be2

Please sign in to comment.