diff --git a/src/Nethermind/Nethermind.Synchronization/FastBlocks/FastHeadersSyncFeed.cs b/src/Nethermind/Nethermind.Synchronization/FastBlocks/FastHeadersSyncFeed.cs index 2521eed6467..8a556c6c9e3 100644 --- a/src/Nethermind/Nethermind.Synchronization/FastBlocks/FastHeadersSyncFeed.cs +++ b/src/Nethermind/Nethermind.Synchronization/FastBlocks/FastHeadersSyncFeed.cs @@ -511,16 +511,12 @@ private void EnqueueBatch(HeadersSyncBatch batch) lastHeader = nextHeader; } - ArrayPoolList reversedBatch = new ArrayPoolList(headers.Count); - foreach (BlockHeader blockHeader in headers.Reverse()) - { - reversedBatch.Add(blockHeader); - } + headers.AsSpan().Reverse(); using HeadersSyncBatch newBatchToProcess = new HeadersSyncBatch(); newBatchToProcess.StartNumber = lastHeader.Number; newBatchToProcess.RequestSize = headers.Count; - newBatchToProcess.Response = reversedBatch; + newBatchToProcess.Response = headers; if (_logger.IsDebug) _logger.Debug($"Handling header portion {newBatchToProcess.StartNumber} to {newBatchToProcess.EndNumber} with persisted headers."); InsertHeaders(newBatchToProcess); @@ -681,6 +677,7 @@ protected virtual int InsertHeaders(HeadersSyncBatch batch) HeadersSyncQueueReport.Update(HeadersInQueue); return added; + // Well, its the last in the batch, but first processed. bool ValidateFirstHeader(BlockHeader header) { BlockHeader lowestInserted = LowestInsertedBlockHeader;