reth_provider/traits/
header_sync_gap.rsuse alloy_consensus::{BlockHeader, Header};
use alloy_eips::BlockHashOrNumber;
use alloy_primitives::{BlockNumber, B256};
use reth_network_p2p::headers::downloader::SyncTarget;
use reth_primitives::SealedHeader;
use reth_storage_errors::provider::ProviderResult;
use tokio::sync::watch;
#[derive(Clone, Debug)]
pub struct HeaderSyncGap<H = Header> {
pub local_head: SealedHeader<H>,
pub target: SyncTarget,
}
impl<H: BlockHeader> HeaderSyncGap<H> {
#[inline]
pub fn is_closed(&self) -> bool {
match self.target.tip() {
BlockHashOrNumber::Hash(hash) => self.local_head.hash() == hash,
BlockHashOrNumber::Number(num) => self.local_head.number() == num,
}
}
}
#[auto_impl::auto_impl(&, Arc)]
pub trait HeaderSyncGapProvider: Send + Sync {
type Header: Send + Sync;
fn sync_gap(
&self,
tip: watch::Receiver<B256>,
highest_uninterrupted_block: BlockNumber,
) -> ProviderResult<HeaderSyncGap<Self::Header>>;
}