Skip to content

Commit

Permalink
Merge pull request openethereum#82 from niklasad1/na-cleanup
Browse files Browse the repository at this point in the history
fix(nits)
  • Loading branch information
soc1c committed Mar 25, 2019
2 parents 455cd93 + 0502915 commit 0b02823
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 9 deletions.
2 changes: 1 addition & 1 deletion ethcore/src/block.rs
Original file line number Diff line number Diff line change
Expand Up @@ -497,7 +497,7 @@ pub(crate) fn enact(
last_hashes,
// Engine such as Clique will calculate author from extra_data.
// this is only important for executing contracts as the 'executive_author'.
engine.executive_author(&header),
engine.executive_author(&header)?,
(3141562.into(), 31415620.into()),
vec![],
is_epoch_begin,
Expand Down
10 changes: 5 additions & 5 deletions ethcore/src/engines/clique/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -153,7 +153,7 @@ impl VoteType {
}

/// Clique Engine implementation
/// block_state_by_hash -> block state indexed by header hash.
// block_state_by_hash -> block state indexed by header hash.
#[cfg(not(test))]
pub struct Clique {
epoch_length: u64,
Expand Down Expand Up @@ -688,7 +688,6 @@ impl Engine<EthereumMachine> for Clique {
}

// Our task here is to set difficulty
// TODO:(niklasad1): Return `Result<(), Error>` here instead
fn populate_from_parent(&self, header: &mut Header, parent: &Header) {
// TODO(https://github.com/paritytech/parity-ethereum/issues/10410): this is a horrible hack,
// it is due to the fact that enact and miner both use OpenBlock::new() which will both call
Expand Down Expand Up @@ -742,6 +741,8 @@ impl Engine<EthereumMachine> for Clique {
fn stop(&mut self) {
if let Some(mut s) = self.step_service.as_mut() {
Arc::get_mut(&mut s).map(|x| x.stop());
} else {
warn!(target: "engine", "Stopping `CliqueStepService` failed requires mutable access");
}
}

Expand All @@ -759,8 +760,7 @@ impl Engine<EthereumMachine> for Clique {
super::total_difficulty_fork_choice(new, current)
}

fn executive_author(&self, header: &Header) -> Address {
// Should have been verified now.
recover_creator(header).expect("Unable to extract creator.")
fn executive_author(&self, header: &Header) -> Result<Address, Error> {
recover_creator(header)
}
}
6 changes: 4 additions & 2 deletions ethcore/src/engines/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,7 @@ impl fmt::Display for EngineError {
FailedSystemCall(ref msg) => format!("Failed to make system call: {}", msg),
MalformedMessage(ref msg) => format!("Received malformed consensus message: {}", msg),
RequiresClient => format!("Call requires client but none registered"),
RequiresSigner => format!("Call requires client but none registered"),
RequiresSigner => format!("Call requires signer but none registered"),
InvalidEngine => format!("Invalid engine specification or implementation"),
};

Expand Down Expand Up @@ -462,7 +462,9 @@ pub trait Engine<M: Machine>: Sync + Send {
fn fork_choice(&self, new: &ExtendedHeader, best: &ExtendedHeader) -> ForkChoice;

/// Returns author should used when executing tx's for this block.
fn executive_author(&self, header: &Header) -> Address { *header.author() }
fn executive_author(&self, header: &Header) -> Result<Address, Error> {
Ok(*header.author())
}
}

/// Check whether a given block is the best block based on the default total difficulty rule.
Expand Down
2 changes: 1 addition & 1 deletion json/src/spec/engine.rs
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,7 @@ mod tests {
let s = r#"{
"clique": {
"params": {
"peorid" : 15,
"period": 15,
"epoch": 30000
}
}
Expand Down

0 comments on commit 0b02823

Please sign in to comment.