Header validator (#12648)

Co-authored-by: Arsenii Kulikov <klkvrr@gmail.com>
This commit is contained in:
0xriazaka.eth
2024-11-19 11:42:40 +01:00
committed by GitHub
parent b78f20f5cb
commit e924bdab37
8 changed files with 152 additions and 137 deletions

View File

@ -9,7 +9,7 @@ use futures::{stream::Stream, FutureExt};
use futures_util::{stream::FuturesUnordered, StreamExt};
use rayon::prelude::*;
use reth_config::config::HeadersConfig;
use reth_consensus::Consensus;
use reth_consensus::{Consensus, HeaderValidator};
use reth_network_p2p::{
error::{DownloadError, DownloadResult, PeerRequestResult},
headers::{

View File

@ -4,7 +4,7 @@ use alloy_consensus::BlockHeader;
use alloy_eips::BlockHashOrNumber;
use alloy_primitives::B256;
use futures::Stream;
use reth_consensus::Consensus;
use reth_consensus::HeaderValidator;
use reth_primitives::SealedHeader;
use reth_primitives_traits::BlockWithParent;
/// A downloader capable of fetching and yielding block headers.
@ -83,7 +83,7 @@ impl SyncTarget {
///
/// Returns Ok(false) if the
pub fn validate_header_download<H: BlockHeader>(
consensus: &dyn Consensus<H>,
consensus: &dyn HeaderValidator<H>,
header: &SealedHeader<H>,
parent: &SealedHeader<H>,
) -> DownloadResult<()> {

View File

@ -147,7 +147,7 @@ impl Stream for TestDownload {
let empty: SealedHeader = SealedHeader::default();
if let Err(error) =
Consensus::<_>::validate_header_against_parent(&this.consensus, &empty, &empty)
<dyn Consensus<_>>::validate_header_against_parent(&this.consensus, &empty, &empty)
{
this.done = true;
return Poll::Ready(Some(Err(DownloadError::HeaderValidation {