mirror of
https://github.com/paradigmxyz/reth.git
synced 2026-01-30 01:28:21 -05:00
pop duplicates entries when returning downloaded blocks in engine (#3644)
Co-authored-by: Matthias Seitz <matthias.seitz@outlook.de>
This commit is contained in:
@@ -13,7 +13,7 @@ use reth_stages::{ControlFlow, Pipeline, PipelineError, PipelineWithResult};
|
||||
use reth_tasks::TaskSpawner;
|
||||
use std::{
|
||||
cmp::{Ordering, Reverse},
|
||||
collections::BinaryHeap,
|
||||
collections::{binary_heap::PeekMut, BinaryHeap},
|
||||
task::{ready, Context, Poll},
|
||||
};
|
||||
use tokio::sync::oneshot;
|
||||
@@ -304,6 +304,14 @@ where
|
||||
|
||||
// drain an element of the block buffer if there are any
|
||||
if let Some(block) = self.range_buffered_blocks.pop() {
|
||||
// peek ahead and pop duplicates
|
||||
while let Some(peek) = self.range_buffered_blocks.peek_mut() {
|
||||
if peek.0 .0.hash() == block.0 .0.hash() {
|
||||
PeekMut::pop(peek);
|
||||
} else {
|
||||
break
|
||||
}
|
||||
}
|
||||
return Poll::Ready(EngineSyncEvent::FetchedFullBlock(block.0 .0))
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user