Refactor BlockImportParams to be non_exhaustive (#4936)

* Refactor BlockImportParams to be non_exhaustive

* Fix cargo check compile
This commit is contained in:
Wei Tang
2020-02-17 10:18:53 +01:00
committed by GitHub
parent 625e963aa2
commit c7b09b642a
16 changed files with 186 additions and 437 deletions
@@ -89,20 +89,11 @@ impl<B: BlockT> Verifier<B> for ManualSealVerifier {
justification: Option<Justification>,
body: Option<Vec<B::Extrinsic>>,
) -> Result<(BlockImportParams<B, ()>, Option<Vec<(CacheKeyId, Vec<u8>)>>), String> {
let import_params = BlockImportParams {
origin,
header,
justification,
post_digests: Vec::new(),
body,
storage_changes: None,
finalized: true,
auxiliary: Vec::new(),
intermediates: HashMap::new(),
fork_choice: Some(ForkChoiceStrategy::LongestChain),
allow_missing_state: false,
import_existing: false,
};
let mut import_params = BlockImportParams::new(origin, header);
import_params.justification = justification;
import_params.body = body;
import_params.finalized = true;
import_params.fork_choice = Some(ForkChoiceStrategy::LongestChain);
Ok((import_params, None))
}
@@ -121,20 +121,10 @@ pub async fn seal_new_block<B, SC, CB, E, T, P>(
}
let (header, body) = proposal.block.deconstruct();
let params = BlockImportParams {
origin: BlockOrigin::Own,
header: header.clone(),
justification: None,
post_digests: Vec::new(),
body: Some(body),
finalized: finalize,
storage_changes: None,
auxiliary: Vec::new(),
intermediates: HashMap::new(),
fork_choice: Some(ForkChoiceStrategy::LongestChain),
allow_missing_state: false,
import_existing: false,
};
let mut params = BlockImportParams::new(BlockOrigin::Own, header.clone());
params.body = Some(body);
params.finalized = finalize;
params.fork_choice = Some(ForkChoiceStrategy::LongestChain);
match block_import.import_block(params, HashMap::new())? {
ImportResult::Imported(aux) => {