Skip to content

Commit

Permalink
fix: handle null blocks in array of blocks to process (#376)
Browse files Browse the repository at this point in the history
  • Loading branch information
Romsters authored Jan 21, 2025
1 parent a766220 commit 1bd495d
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
4 changes: 2 additions & 2 deletions packages/worker/src/block/block.processor.ts
Original file line number Diff line number Diff line change
Expand Up @@ -78,12 +78,12 @@ export class BlockProcessor {
return false;
}

if (lastDbBlock && lastDbBlock.hash !== blocksToProcess[0].block?.parentHash) {
if (lastDbBlock && lastDbBlock.hash !== blocksToProcess[0]?.block?.parentHash) {
this.triggerBlocksRevertEvent(lastDbBlockNumber);
return false;
}

const allBlocksExist = !blocksToProcess.find((blockInfo) => !blockInfo.block || !blockInfo.blockDetails);
const allBlocksExist = !blocksToProcess.find((blockInfo) => !blockInfo?.block || !blockInfo?.blockDetails);
if (!allBlocksExist) {
// We don't need to handle this potential revert as these blocks are not in DB yet,
// try again later once these blocks are present in blockchain again.
Expand Down
2 changes: 1 addition & 1 deletion packages/worker/src/blocksRevert/blocksRevert.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ export class BlocksRevertService {
lastExecutedBlockNumber: number,
detectedIncorrectBlockNumber: number
) => {
// binary search the last block with matching hash between latest executed block from DB and incorrect clock detected
// binary search the last block with matching hash between latest executed block from DB and incorrect block detected
let start = lastExecutedBlockNumber;
let end = detectedIncorrectBlockNumber;

Expand Down

0 comments on commit 1bd495d

Please sign in to comment.