Skip to content
This repository has been archived by the owner on Jun 11, 2024. It is now read-only.

Commit

Permalink
Optimize code
Browse files Browse the repository at this point in the history
  • Loading branch information
priojeetpriyom committed Oct 24, 2023
1 parent bf2334a commit d83e1a6
Showing 1 changed file with 3 additions and 8 deletions.
11 changes: 3 additions & 8 deletions services/blockchain-indexer/shared/indexer/blockchainIndex.js
Original file line number Diff line number Diff line change
Expand Up @@ -365,7 +365,7 @@ const deleteIndexedBlocks = async job => {
const { height: lastIndexedHeight } = lastIndexedBlock;

// Skip deletion if the lisk-service has not indexed the block previously.
// The fork does have any impact on block indexing in this case.
// The fork doesn't have any impact on block indexing in this case.
if (blockFromJob.height > lastIndexedHeight || !blockFromDB) {
return;
}
Expand Down Expand Up @@ -400,7 +400,7 @@ const deleteIndexedBlocks = async job => {
},
{ concurrency: 25 },
);
forkedTransactions = transactionsToDelete.map(e => e !== null);
forkedTransactions = transactionsToDelete.map(t => t !== null);
}
await transactionsTable.deleteByPrimaryKey(forkedTransactionIDs, dbTrx);
Signals.get('deleteTransactions').dispatch({ data: forkedTransactions });
Expand Down Expand Up @@ -593,20 +593,15 @@ const indexNewBlock = async block => {

// Schedule block deletion incase unprocessed fork found
if (blockFromDB && blockFromDB.id !== block.id) {
const [highestIndexedBlock] = await blocksTable.find({ sort: 'height:desc', limit: 1 }, [
'height',
]);
const blocksToRemove = await blocksTable.find(
{
propBetweens: [
{
property: 'height',
from: block.height,
to: highestIndexedBlock.height,
},
],
sort: 'height:desc',
limit: highestIndexedBlock.height - block.height + 1,
},
['id'],
);
Expand All @@ -618,7 +613,7 @@ const indexNewBlock = async block => {
await indexBlocksQueue.add({ height: block.height });
}

// Update finality status of indexed block
// Update finality status of indexed blocks
const finalizedBlockHeight = await getFinalizedHeight();
await blocksTable.update({
where: {
Expand Down

0 comments on commit d83e1a6

Please sign in to comment.