Skip to content
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

fix(nits) #82

Merged
merged 1 commit into from
Mar 25, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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