;
/// Get completion data by header hash.
async fn header_completion(&self, id: HeaderIdOf)
-> Result<(HeaderIdOf
, Option), Self::Error>;
/// Get extra data by header hash.
async fn header_extra(
&self,
id: HeaderIdOf,
header: QueuedHeader
,
) -> Result<(HeaderIdOf
, P::Extra), Self::Error>;
}
/// Target client trait.
#[async_trait]
pub trait TargetClient: Sized {
/// Type of error this clients returns.
type Error: std::fmt::Debug + MaybeConnectionError;
/// Returns ID of best header known to the target node.
async fn best_header_id(&self) -> Result, Self::Error>;
/// Returns true if header is known to the target node.
async fn is_known_header(&self, id: HeaderIdOf) -> Result<(HeaderIdOf
, bool), Self::Error>;
/// Submit headers.
async fn submit_headers(&self, headers: Vec>) -> SubmittedHeaders, Self::Error>;
/// Returns ID of headers that require to be 'completed' before children can be submitted.
async fn incomplete_headers_ids(&self) -> Result>, Self::Error>;
/// Submit completion data for header.
async fn complete_header(&self, id: HeaderIdOf, completion: P::Completion)
-> Result, Self::Error>;
/// Returns true if header requires extra data to be submitted.
async fn requires_extra(&self, header: QueuedHeader) -> Result<(HeaderIdOf
, bool), Self::Error>;
}
/// Run headers synchronization.
pub fn run>(
source_client: impl SourceClient,
source_tick: Duration,
target_client: TC,
target_tick: Duration,
sync_params: HeadersSyncParams,
metrics_params: Option,
exit_signal: impl Future