mirror of
https://github.com/hl-archive-node/nanoreth.git
synced 2025-12-06 19:09:54 +00:00
perf(download): parallel header sealing (#1536)
This commit is contained in:
1
Cargo.lock
generated
1
Cargo.lock
generated
@ -4506,6 +4506,7 @@ dependencies = [
|
||||
"itertools 0.10.5",
|
||||
"metrics",
|
||||
"pin-project",
|
||||
"rayon",
|
||||
"reth-db",
|
||||
"reth-eth-wire",
|
||||
"reth-interfaces",
|
||||
|
||||
@ -26,6 +26,7 @@ tokio-stream = "0.1"
|
||||
# misc
|
||||
tracing = "0.1.37"
|
||||
metrics = "0.20.1"
|
||||
rayon = "1.6.0"
|
||||
|
||||
# optional deps for the test-utils feature
|
||||
thiserror = { version = "1", optional = true }
|
||||
|
||||
@ -4,6 +4,7 @@ use super::task::TaskDownloader;
|
||||
use crate::metrics::DownloaderMetrics;
|
||||
use futures::{stream::Stream, FutureExt};
|
||||
use futures_util::{stream::FuturesUnordered, StreamExt};
|
||||
use rayon::prelude::*;
|
||||
use reth_interfaces::{
|
||||
consensus::Consensus,
|
||||
p2p::{
|
||||
@ -200,9 +201,8 @@ where
|
||||
let sync_target_hash = self.existing_sync_target_hash();
|
||||
let mut validated = Vec::with_capacity(headers.len());
|
||||
|
||||
for parent in headers {
|
||||
let parent = parent.seal_slow();
|
||||
|
||||
let sealed_headers = headers.into_par_iter().map(|h| h.seal_slow()).collect::<Vec<_>>();
|
||||
for parent in sealed_headers {
|
||||
// Validate that the header is the parent header of the last validated header.
|
||||
if let Some(validated_header) =
|
||||
validated.last().or_else(|| self.lowest_validated_header())
|
||||
|
||||
Reference in New Issue
Block a user