Skip to content

Commit

Permalink
Fix2
Browse files Browse the repository at this point in the history
  • Loading branch information
MayNail committed Sep 30, 2020
1 parent b8f48d6 commit f742ad8
Showing 1 changed file with 20 additions and 22 deletions.
42 changes: 20 additions & 22 deletions core/crfg/src/import.rs
Expand Up @@ -562,6 +562,26 @@ impl<B, E, Block: BlockT<Hash=H256>, RA, PRA> BlockImport<Block>
let skip = self.check_skip(&mut block, finalized_number)?;
let pending_changes = self.make_authorities_changes(&mut block, hash)?;

// we don't want to finalize on `inner.import_block`
let mut justification = block.justification.take();
let enacts_consensus_change = !new_cache.is_empty();
let import_result = self.inner.import_block(block, new_cache);

let mut imported_aux = {
match import_result {
Ok(ImportResult::Imported(aux)) => aux,
Ok(r) => {
debug!(target: "afg", "Restoring old authority set after block import result: {:?}", r);
pending_changes.revert();
return Ok(r);
},
Err(e) => {
debug!(target: "afg", "Restoring old authority set after block import error: {:?}", e);
pending_changes.revert();
return Err(ConsensusErrorKind::ClientImport(e.to_string()).into());
},
}
};

// skip
if finalized_number + As::sa(srml_finality_tracker::STALL_LATENCY) <= number {
Expand Down Expand Up @@ -622,28 +642,6 @@ impl<B, E, Block: BlockT<Hash=H256>, RA, PRA> BlockImport<Block>
}
}


// we don't want to finalize on `inner.import_block`
let mut justification = block.justification.take();
let enacts_consensus_change = !new_cache.is_empty();
let import_result = self.inner.import_block(block, new_cache);

let mut imported_aux = {
match import_result {
Ok(ImportResult::Imported(aux)) => aux,
Ok(r) => {
debug!(target: "afg", "Restoring old authority set after block import result: {:?}", r);
pending_changes.revert();
return Ok(r);
},
Err(e) => {
debug!(target: "afg", "Restoring old authority set after block import error: {:?}", e);
pending_changes.revert();
return Err(ConsensusErrorKind::ClientImport(e.to_string()).into());
},
}
};

let (applied_changes, do_pause) = pending_changes.defuse();

debug!(target: "afg", "Applied changes, number: {}, hash: {}, applied_changes: {:?}", number, hash, applied_changes);
Expand Down

0 comments on commit f742ad8

Please sign in to comment.