From d703f4d63ed963ab8078b7bb6d25c0a23e84f670 Mon Sep 17 00:00:00 2001 From: Martin Minkov Date: Tue, 21 Nov 2023 08:22:55 -0800 Subject: [PATCH] fix(mina-consensus.ts): correct the splice index in filterBestTip (#93) 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. --- src/consensus/mina-consensus.ts | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/consensus/mina-consensus.ts b/src/consensus/mina-consensus.ts index 0b106a1..6a2f389 100644 --- a/src/consensus/mina-consensus.ts +++ b/src/consensus/mina-consensus.ts @@ -24,7 +24,12 @@ function filterBestTip( ); 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 + ); } }