Skip to content

Commit

Permalink
Bring back --update-block-height option
Browse files Browse the repository at this point in the history
  • Loading branch information
vgrichina committed Apr 30, 2024
1 parent 4871cd4 commit 8c52d70
Showing 1 changed file with 11 additions and 2 deletions.
13 changes: 11 additions & 2 deletions scripts/load-from-source.js
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ async function handleStreamerMessage(streamerMessage, options = {}) {
}
}

async function dumpChangesToStorage(streamerMessage, { historyLength, include, exclude } = {}) {
async function dumpChangesToStorage(streamerMessage, { historyLength, updateBlockHeight = true, include, exclude } = {}) {
// TODO: Use timestampNanoSec?
const { height: blockHeight, hash: blockHashB58, timestamp } = streamerMessage.block.header;
const blockHash = bs58.decode(blockHashB58);
Expand All @@ -59,7 +59,9 @@ async function dumpChangesToStorage(streamerMessage, { historyLength, include, e
});

await storage.setBlockTimestamp(blockHeight, timestamp);
await storage.setLatestBlockHeight(blockHeight);
if (updateBlockHeight) {
await storage.setLatestBlockHeight(blockHeight);
}
console.timeEnd('dumpChangesToStorage');
// TODO: Record block hash to block height mapping?
}
Expand Down Expand Up @@ -193,6 +195,11 @@ if (require.main === module) {
default: ['0', '1', '2', '3'],
array: true,
})
.option('update-block-height', {
describe: 'update block height in storage',
boolean: true,
default: true
})
.option('include', {
describe: 'include only accounts matching this glob pattern. Can be specified multiple times.',
array: true
Expand Down Expand Up @@ -236,6 +243,7 @@ if (require.main === module) {
batchSize,
historyLength,
limit,
updateBlockHeight,
include,
exclude,
dumpChanges,
Expand All @@ -259,6 +267,7 @@ if (require.main === module) {
await handleStreamerMessage(streamerMessage, {
batchSize,
historyLength,
updateBlockHeight,
include,
exclude,
dumpChanges,
Expand Down

0 comments on commit 8c52d70

Please sign in to comment.