diff --git a/ethcore/src/engines/mod.rs b/ethcore/src/engines/mod.rs index 9cf112bf1..599721f86 100644 --- a/ethcore/src/engines/mod.rs +++ b/ethcore/src/engines/mod.rs @@ -72,8 +72,10 @@ pub trait Engine : Sync + Send { fn on_close_block(&self, _block: &mut ExecutedBlock) {} /// If Some(true) this author is able to generate seals, generate_seal has to be implemented. - /// None indicates that this engine does not seal internally regardless of author (e.g. PoW). + /// None indicates that this Engine never seals internally regardless of author (e.g. PoW). fn is_sealer(&self, _author: &Address) -> Option { None } + /// Checks if default address is able to seal. + fn is_default_sealer(&self) -> Option { self.is_sealer(&Default::default()) } /// Attempt to seal the block internally. /// /// If `Some` is returned, then you get a valid seal. diff --git a/ethcore/src/miner/miner.rs b/ethcore/src/miner/miner.rs index 502c78402..ad963b167 100644 --- a/ethcore/src/miner/miner.rs +++ b/ethcore/src/miner/miner.rs @@ -190,8 +190,6 @@ pub struct Miner { impl Miner { /// Creates new instance of miner without accounts, but with given spec. pub fn with_spec(spec: &Spec) -> Miner { - let author = Address::default(); - let is_sealer = spec.engine.is_sealer(&author); Miner { transaction_queue: Arc::new(Mutex::new(TransactionQueue::new())), options: Default::default(), @@ -199,11 +197,11 @@ impl Miner { sealing_block_last_request: Mutex::new(0), sealing_work: Mutex::new(SealingWork{ queue: UsingQueue::new(20), - enabled: is_sealer.unwrap_or(false) + enabled: spec.engine.is_default_sealer().unwrap_or(false) }), - seals_internally: is_sealer.is_some(), + seals_internally: spec.engine.is_default_sealer().is_some(), gas_range_target: RwLock::new((U256::zero(), U256::zero())), - author: RwLock::new(author), + author: RwLock::new(Address::default()), extra_data: RwLock::new(Vec::new()), accounts: None, engine: spec.engine.clone(), @@ -216,8 +214,6 @@ impl Miner { pub fn new(options: MinerOptions, gas_pricer: GasPricer, spec: &Spec, accounts: Option>) -> Arc { let work_poster = if !options.new_work_notify.is_empty() { Some(WorkPoster::new(&options.new_work_notify)) } else { None }; let txq = Arc::new(Mutex::new(TransactionQueue::with_limits(options.tx_queue_size, options.tx_gas_limit))); - let author = Address::default(); - let is_sealer = spec.engine.is_sealer(&author); Arc::new(Miner { transaction_queue: txq, next_allowed_reseal: Mutex::new(Instant::now()), @@ -226,11 +222,11 @@ impl Miner { queue: UsingQueue::new(options.work_queue_size), enabled: options.force_sealing || !options.new_work_notify.is_empty() - || is_sealer.unwrap_or(false) + || spec.engine.is_default_sealer().unwrap_or(false) }), - seals_internally: is_sealer.is_some(), + seals_internally: spec.engine.is_default_sealer().is_some(), gas_range_target: RwLock::new((U256::zero(), U256::zero())), - author: RwLock::new(author), + author: RwLock::new(Address::default()), extra_data: RwLock::new(Vec::new()), options: options, accounts: accounts,