pop duplicates entries when returning downloaded blocks in engine (#3644)

Co-authored-by: Matthias Seitz <matthias.seitz@outlook.de>
This commit is contained in:
Chris Evanko
2023-07-07 14:51:34 -04:00
committed by GitHub
parent 526f624e1c
commit 93865ef916

View File

@@ -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))
}