Skip to content

Commit

Permalink
Merge pull request openethereum#64 from niklasad1/revert-bad-change
Browse files Browse the repository at this point in the history
fix(clique sealing): don't read state if there is no signer available
  • Loading branch information
jwasinger authored Mar 13, 2019
2 parents 941d454 + 12ac5be commit 5fa0228
Showing 1 changed file with 8 additions and 8 deletions.
16 changes: 8 additions & 8 deletions ethcore/src/engines/clique/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -680,17 +680,17 @@ impl Engine<EthereumMachine> for Clique {
if header.extra_data().len() < VANITY_LENGTH + SIGNATURE_LENGTH {
trace!(target: "engine", "populate_from_parent in sealing");

let state = match self.state(&parent) {
Err(e) => {
trace!(target: "engine", "populate_from_parent: Unable to find parent state: {}, ignored.", e);
return;
}
Ok(state) => state,
};

// It's unclear how to prevent creating new blocks unless we are authorized, the best way (and geth does this too)
// it's just to ignore setting an correct difficulty here, we will check authorization in next step in generate_seal anyway.
if let Some(signer) = self.signer.read().as_ref() {
let state = match self.state(&parent) {
Err(e) => {
trace!(target: "engine", "populate_from_parent: Unable to find parent state: {}, ignored.", e);
return;
}
Ok(state) => state,
};

if state.is_authorized(&signer.address()) {
if state.is_inturn(header.number(), &signer.address()) {
header.set_difficulty(DIFF_INTURN);
Expand Down

0 comments on commit 5fa0228

Please sign in to comment.