@@ -36,7 +36,6 @@ use super::mem_pool::{Error as MemPoolError, MemPool};
3636pub use super :: mem_pool_types:: MemPoolFees ;
3737use super :: mem_pool_types:: { AccountDetails , MemPoolInput , TxOrigin , TxTimelock } ;
3838use super :: sealing_queue:: SealingQueue ;
39- use super :: work_notify:: { NotifyWork , WorkPoster } ;
4039use super :: { MinerService , MinerStatus , TransactionImportResult } ;
4140use crate :: account_provider:: { AccountProvider , Error as AccountProviderError } ;
4241use crate :: block:: { Block , ClosedBlock , IsBlock } ;
@@ -54,8 +53,6 @@ use std::borrow::Borrow;
5453/// Configures the behaviour of the miner.
5554#[ derive( Debug , PartialEq ) ]
5655pub struct MinerOptions {
57- /// URLs to notify when there is new work.
58- pub new_work_notify : Vec < String > ,
5956 /// Force the miner to reseal, even when nobody has asked for work.
6057 pub force_sealing : bool ,
6158 /// Reseal on receipt of new external transactions.
@@ -87,7 +84,6 @@ pub struct MinerOptions {
8784impl Default for MinerOptions {
8885 fn default ( ) -> Self {
8986 MinerOptions {
90- new_work_notify : vec ! [ ] ,
9187 force_sealing : false ,
9288 reseal_on_external_transaction : true ,
9389 reseal_on_own_transaction : true ,
@@ -131,17 +127,11 @@ pub struct Miner {
131127 sealing_enabled : AtomicBool ,
132128
133129 accounts : Option < Arc < AccountProvider > > ,
134- notifiers : RwLock < Vec < Box < dyn NotifyWork > > > ,
135130 malicious_users : RwLock < HashSet < Address > > ,
136131 immune_users : RwLock < HashSet < Address > > ,
137132}
138133
139134impl Miner {
140- /// Push listener that will handle new jobs
141- pub fn add_work_listener ( & self , notifier : Box < dyn NotifyWork > ) {
142- self . notifiers . write ( ) . push ( notifier) ;
143- }
144-
145135 pub fn new (
146136 options : MinerOptions ,
147137 scheme : & Scheme ,
@@ -170,12 +160,6 @@ impl Miner {
170160 options. mem_pool_fees ,
171161 ) ) ) ;
172162
173- let notifiers: Vec < Box < dyn NotifyWork > > = if options. new_work_notify . is_empty ( ) {
174- Vec :: new ( )
175- } else {
176- vec ! [ Box :: new( WorkPoster :: new( & options. new_work_notify) ) ]
177- } ;
178-
179163 Self {
180164 mem_pool,
181165 transaction_listener : RwLock :: new ( vec ! [ ] ) ,
@@ -191,7 +175,6 @@ impl Miner {
191175 options,
192176 sealing_enabled : AtomicBool :: new ( true ) ,
193177 accounts,
194- notifiers : RwLock :: new ( notifiers) ,
195178 malicious_users : RwLock :: new ( HashSet :: new ( ) ) ,
196179 immune_users : RwLock :: new ( HashSet :: new ( ) ) ,
197180 }
@@ -412,50 +395,29 @@ impl Miner {
412395
413396 /// Prepares work which has to be done to seal.
414397 fn prepare_work ( & self , block : ClosedBlock , original_work_hash : Option < H256 > ) {
415- let ( work, is_new) = {
416- let mut sealing_work = self . sealing_work . lock ( ) ;
417- let last_work_hash = sealing_work. queue . peek_last_ref ( ) . map ( |pb| pb. block ( ) . header ( ) . hash ( ) ) ;
398+ let mut sealing_work = self . sealing_work . lock ( ) ;
399+ let last_work_hash = sealing_work. queue . peek_last_ref ( ) . map ( |pb| pb. block ( ) . header ( ) . hash ( ) ) ;
400+ ctrace ! (
401+ MINER ,
402+ "prepare_work: Checking whether we need to reseal: orig={:?} last={:?}, this={:?}" ,
403+ original_work_hash,
404+ last_work_hash,
405+ block. block( ) . header( ) . hash( )
406+ ) ;
407+ if last_work_hash. map_or ( true , |h| h != block. block ( ) . header ( ) . hash ( ) ) {
418408 ctrace ! (
419409 MINER ,
420- "prepare_work: Checking whether we need to reseal: orig={:?} last={:?}, this={:?}" ,
421- original_work_hash,
422- last_work_hash,
410+ "prepare_work: Pushing a new, refreshed or borrowed pending {}..." ,
423411 block. block( ) . header( ) . hash( )
424412 ) ;
425- let ( work, is_new) = if last_work_hash. map_or ( true , |h| h != block. block ( ) . header ( ) . hash ( ) ) {
426- ctrace ! (
427- MINER ,
428- "prepare_work: Pushing a new, refreshed or borrowed pending {}..." ,
429- block. block( ) . header( ) . hash( )
430- ) ;
431- let pow_hash = * block. block ( ) . header ( ) . hash ( ) ;
432- let number = block. block ( ) . header ( ) . number ( ) ;
433- let score = * block. block ( ) . header ( ) . score ( ) ;
434- let is_new = original_work_hash. map_or ( true , |h| * block. block ( ) . header ( ) . hash ( ) != h) ;
435- sealing_work. queue . push ( block) ;
436- // If push notifications are enabled we assume all work items are used.
437- if !self . notifiers . read ( ) . is_empty ( ) && is_new {
438- sealing_work. queue . use_last_ref ( ) ;
439- }
440- ( Some ( ( pow_hash, score, number) ) , is_new)
441- } else {
442- ( None , false )
443- } ;
444- ctrace ! (
445- MINER ,
446- "prepare_work: leaving (last={:?})" ,
447- sealing_work. queue. peek_last_ref( ) . map( |b| b. block( ) . header( ) . hash( ) )
448- ) ;
449- ( work, is_new)
413+ sealing_work. queue . push ( block) ;
414+ // If push notifications are enabled we assume all work items are used.
450415 } ;
451- if is_new {
452- if let Some ( ( pow_hash, score, _number) ) = work {
453- let target = self . engine . score_to_target ( & score) ;
454- for notifier in self . notifiers . read ( ) . iter ( ) {
455- notifier. notify ( pow_hash, target)
456- }
457- }
458- }
416+ ctrace ! (
417+ MINER ,
418+ "prepare_work: leaving (last={:?})" ,
419+ sealing_work. queue. peek_last_ref( ) . map( |b| b. block( ) . header( ) . hash( ) )
420+ ) ;
459421 }
460422
461423 /// Prepares new block for sealing including top transactions from queue.
0 commit comments