From 7f707fa524baaaccac499d69f9e452b380c31ffa Mon Sep 17 00:00:00 2001 From: Marek Kotewicz Date: Tue, 16 Jul 2019 12:52:29 +0200 Subject: [PATCH] return block nonce when engine is clique (#10892) * return block nonce when engine is clique, closes #10534 * Apply suggestions from code review Co-Authored-By: Niklas Adolfsson --- ethcore/src/engines/clique/mod.rs | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/ethcore/src/engines/clique/mod.rs b/ethcore/src/engines/clique/mod.rs index adfcf88f0..3674c5c8d 100644 --- a/ethcore/src/engines/clique/mod.rs +++ b/ethcore/src/engines/clique/mod.rs @@ -59,8 +59,7 @@ /// in order to import the new block. use std::cmp; -use std::collections::HashMap; -use std::collections::VecDeque; +use std::collections::{HashMap, VecDeque, BTreeMap}; use std::sync::{Arc, Weak}; use std::thread; use std::time; @@ -84,6 +83,7 @@ use unexpected::{Mismatch, OutOfBounds}; use time_utils::CheckedSystemTime; use types::BlockNumber; use types::header::Header; +use ethereum::ethash; use self::block_state::CliqueBlockState; use self::params::CliqueParams; @@ -362,6 +362,17 @@ impl Engine for Clique { // Clique use same fields, nonce + mixHash fn seal_fields(&self, _header: &Header) -> usize { 2 } + fn extra_info(&self, header: &Header) -> BTreeMap { + // clique engine seal fields are the same as ethash seal fields + match ethash::Seal::parse_seal(header.seal()) { + Ok(seal) => map![ + "nonce".to_owned() => format!("{:#x}", seal.nonce), + "mixHash".to_owned() => format!("{:#x}", seal.mix_hash) + ], + _ => BTreeMap::default() + } + } + fn maximum_uncle_count(&self, _block: BlockNumber) -> usize { 0 } fn on_new_block(