Skip to content

Stop generating blocks if the consensus cannot make a seal #1792

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Sep 26, 2019

Conversation

majecty
Copy link
Contributor

@majecty majecty commented Sep 24, 2019

If the Tendermint consensus receives an outdated block request, it returns
an empty seal. The miner should stop block generation if the seal is empty.

@majecty majecty added the bug Something isn't working label Sep 24, 2019
@ScarletBlue ScarletBlue changed the title Stop generating block if consensus cannot make a seal Stop generating blocks if the consensus cannot make a seal Sep 24, 2019
If Tendermint consensus received an outdated block request, it returns
empty seal. Miner should stop the block generation if the seal is empty.
@@ -837,13 +840,17 @@ impl MinerService for Miner {
let parent_block_number = chain.block_header(&parent_block).expect("Parent is always exist").number();
if self.requires_reseal(parent_block_number) {
let (block, original_work_hash) = match self.prepare_block(parent_block, chain) {
Ok((block, original_work_hash)) => {
Ok(Some((block, original_work_hash))) => {
Copy link
Contributor

@foriequal0 foriequal0 Sep 25, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

BTW, block and original_work_hash are duplicated 3 times. It can be reduced with

let (block, original_work_hash) = match ... {
  Ok(Some(prepared @ (block, _))) => { 
    ...
    prepared
  }
  ...
};

@majecty majecty merged commit 062fc76 into CodeChain-io:master Sep 26, 2019
@majecty majecty deleted the f/seal-empty branch September 26, 2019 06:45
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants