Add --only-mandatory-headers mode (#1004)

This commit is contained in:
Svyatoslav Nikolsky
2021-06-16 22:03:03 +03:00
committed by Bastian Köcher
parent 09df16612b
commit c69c682a4c
6 changed files with 260 additions and 58 deletions
+8 -1
View File
@@ -58,6 +58,8 @@ pub struct FinalitySyncParams {
pub recent_finality_proofs_limit: usize,
/// Timeout before we treat our transactions as lost and restart the whole sync process.
pub stall_timeout: Duration,
/// If true, only mandatory headers are relayed.
pub only_mandatory_headers: bool,
}
/// Source client used in finality synchronization loop.
@@ -364,7 +366,7 @@ where
}
}
async fn select_header_to_submit<P, SC, TC>(
pub(crate) async fn select_header_to_submit<P, SC, TC>(
source_client: &SC,
target_client: &TC,
finality_proofs_stream: &mut RestartableFinalityProofsStream<SC::FinalityProofsStream>,
@@ -397,6 +399,11 @@ where
.await?;
let (mut unjustified_headers, mut selected_finality_proof) = match selected_finality_proof {
SelectedFinalityProof::Mandatory(header, finality_proof) => return Ok(Some((header, finality_proof))),
_ if sync_params.only_mandatory_headers => {
// we are not reading finality proofs from the stream, so eventually it'll break
// but we don't care about transient proofs at all, so it is acceptable
return Ok(None);
}
SelectedFinalityProof::Regular(unjustified_headers, header, finality_proof) => {
(unjustified_headers, Some((header, finality_proof)))
}