mirror of
https://github.com/paradigmxyz/reth.git
synced 2026-04-30 03:01:58 -04:00
perf: ignore download request if already inflight (#2856)
This commit is contained in:
@@ -558,7 +558,7 @@ where
|
||||
self.sync.set_pipeline_sync_target(target);
|
||||
} else {
|
||||
// trigger a full block download for the _missing_ new head
|
||||
self.sync.download_full_block(state.head_block_hash)
|
||||
self.sync.download_full_block(state.head_block_hash);
|
||||
}
|
||||
|
||||
PayloadStatus::from_status(PayloadStatusEnum::Syncing)
|
||||
|
||||
@@ -100,8 +100,19 @@ where
|
||||
self.pipeline_state.is_idle()
|
||||
}
|
||||
|
||||
/// Returns true if there's already a request for the given hash.
|
||||
pub(crate) fn is_inflight_request(&self, hash: H256) -> bool {
|
||||
self.inflight_full_block_requests.iter().any(|req| *req.hash() == hash)
|
||||
}
|
||||
|
||||
/// Starts requesting a full block from the network.
|
||||
pub(crate) fn download_full_block(&mut self, hash: H256) {
|
||||
///
|
||||
/// Returns `true` if the request was started, `false` if there's already a request for the
|
||||
/// given hash.
|
||||
pub(crate) fn download_full_block(&mut self, hash: H256) -> bool {
|
||||
if self.is_inflight_request(hash) {
|
||||
return false
|
||||
}
|
||||
trace!(
|
||||
target: "consensus::engine",
|
||||
?hash,
|
||||
@@ -109,6 +120,7 @@ where
|
||||
);
|
||||
let request = self.full_block_client.get_full_block(hash);
|
||||
self.inflight_full_block_requests.push(request);
|
||||
true
|
||||
}
|
||||
|
||||
/// Sets a new target to sync the pipeline to.
|
||||
|
||||
Reference in New Issue
Block a user