From bae6a5eeecab7296f852f6c1295da13e62232a29 Mon Sep 17 00:00:00 2001 From: Robert Habermeier Date: Thu, 5 Oct 2017 15:34:30 +0200 Subject: [PATCH] move additional_info to engines, fixes registry on non-ethash chains --- ethcore/src/engines/mod.rs | 8 +++++--- ethcore/src/ethereum/ethash.rs | 6 ++---- ethcore/src/machine.rs | 9 ++++++++- 3 files changed, 15 insertions(+), 8 deletions(-) diff --git a/ethcore/src/engines/mod.rs b/ethcore/src/engines/mod.rs index 5078ebc3a..2e583b179 100644 --- a/ethcore/src/engines/mod.rs +++ b/ethcore/src/engines/mod.rs @@ -191,9 +191,6 @@ pub trait Engine: Sync + Send { /// Additional engine-specific information for the user/developer concerning `header`. fn extra_info(&self, _header: &M::Header) -> BTreeMap { BTreeMap::new() } - /// Additional information. - fn additional_params(&self) -> HashMap { HashMap::new() } - /// Maximum number of uncles a block is allowed to declare. fn maximum_uncle_count(&self) -> usize { 2 } /// The number of generations back that uncles can be. @@ -396,6 +393,11 @@ pub trait EthEngine: Engine<::machine::EthereumMachine> { fn supports_wasm(&self) -> bool { self.machine().supports_wasm() } + + /// Additional information. + fn additional_params(&self) -> HashMap { + self.machine().additional_params() + } } // convenience wrappers for existing functions. diff --git a/ethcore/src/ethereum/ethash.rs b/ethcore/src/ethereum/ethash.rs index e7a75af58..e0a85ab9f 100644 --- a/ethcore/src/ethereum/ethash.rs +++ b/ethcore/src/ethereum/ethash.rs @@ -16,7 +16,7 @@ use std::path::Path; use std::cmp; -use std::collections::{BTreeMap, HashMap}; +use std::collections::BTreeMap; use std::sync::Arc; use hash::{KECCAK_EMPTY_LIST_RLP}; use ethash::{quick_get_difficulty, slow_hash_block_number, EthashManager, OptimizeFor}; @@ -26,7 +26,7 @@ use unexpected::{OutOfBounds, Mismatch}; use block::*; use error::{BlockError, Error}; use header::Header; -use engines::{self, Engine, EthEngine}; +use engines::{self, Engine}; use ethjson; use rlp::{self, UntrustedRlp}; use machine::EthereumMachine; @@ -150,8 +150,6 @@ impl Engine for Arc { // Two fields - nonce and mix. fn seal_fields(&self) -> usize { 2 } - fn additional_params(&self) -> HashMap { hash_map!["registrar".to_owned() => self.params().registrar.hex()] } - /// Additional engine-specific information for the user/developer concerning `header`. fn extra_info(&self, header: &Header) -> BTreeMap { if header.seal().len() == self.seal_fields() { diff --git a/ethcore/src/machine.rs b/ethcore/src/machine.rs index 5b37947db..b1354b17b 100644 --- a/ethcore/src/machine.rs +++ b/ethcore/src/machine.rs @@ -16,7 +16,7 @@ //! Ethereum-like state machine definition. -use std::collections::BTreeMap; +use std::collections::{BTreeMap, HashMap}; use std::cmp; use std::sync::Arc; @@ -378,6 +378,13 @@ impl EthereumMachine { pub fn supports_wasm(&self) -> bool { self.params().wasm } + + /// Additional params. + pub fn additional_params(&self) -> HashMap { + hash_map![ + "registrar".to_owned() => self.params.registrar.hex() + ] + } } /// Auxiliary data fetcher for an Ethereum machine. In Ethereum-like machines