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 <niklasadolfsson1@gmail.com>
This commit is contained in:
Marek Kotewicz 2019-07-16 12:52:29 +02:00 committed by GitHub
parent c62e97d3c4
commit 7f707fa524
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -59,8 +59,7 @@
/// in order to import the new block. /// in order to import the new block.
use std::cmp; use std::cmp;
use std::collections::HashMap; use std::collections::{HashMap, VecDeque, BTreeMap};
use std::collections::VecDeque;
use std::sync::{Arc, Weak}; use std::sync::{Arc, Weak};
use std::thread; use std::thread;
use std::time; use std::time;
@ -84,6 +83,7 @@ use unexpected::{Mismatch, OutOfBounds};
use time_utils::CheckedSystemTime; use time_utils::CheckedSystemTime;
use types::BlockNumber; use types::BlockNumber;
use types::header::Header; use types::header::Header;
use ethereum::ethash;
use self::block_state::CliqueBlockState; use self::block_state::CliqueBlockState;
use self::params::CliqueParams; use self::params::CliqueParams;
@ -362,6 +362,17 @@ impl Engine for Clique {
// Clique use same fields, nonce + mixHash // Clique use same fields, nonce + mixHash
fn seal_fields(&self, _header: &Header) -> usize { 2 } fn seal_fields(&self, _header: &Header) -> usize { 2 }
fn extra_info(&self, header: &Header) -> BTreeMap<String, String> {
// 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 maximum_uncle_count(&self, _block: BlockNumber) -> usize { 0 }
fn on_new_block( fn on_new_block(