Skip to content

Commit

Permalink
fix(mina-consensus.ts): correct the splice index in filterBestTip (#93)
Browse files Browse the repository at this point in the history
The previous implementation was incorrectly splicing from the start of
the array, which could lead to unexpected results. The fix ensures that
the splice operation starts from the correct index, preserving the
integrity of the array.
  • Loading branch information
MartinMinkov authored Nov 21, 2023
1 parent 4a11e21 commit d703f4d
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion src/consensus/mina-consensus.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,12 @@ function filterBestTip<T extends { blockInfo: BlockInfo }>(
);
if (highestTipBlocks.length > 1) {
const selectedBlock = chainSelect(highestTipBlocks);
eventOrActionData.splice(0, highestTipBlocks.length + 1, selectedBlock);
const startIndex = eventOrActionData.length - highestTipBlocks.length;
eventOrActionData.splice(
startIndex,
highestTipBlocks.length,
selectedBlock
);
}
}

Expand Down

0 comments on commit d703f4d

Please sign in to comment.