@@ -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:: { 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.
@@ -85,7 +82,6 @@ pub struct MinerOptions {
8582impl Default for MinerOptions {
8683 fn default ( ) -> Self {
8784 MinerOptions {
88- new_work_notify : vec ! [ ] ,
8985 force_sealing : false ,
9086 reseal_on_external_transaction : true ,
9187 reseal_on_own_transaction : true ,
@@ -128,17 +124,11 @@ pub struct Miner {
128124 sealing_enabled : AtomicBool ,
129125
130126 accounts : Option < Arc < AccountProvider > > ,
131- notifiers : RwLock < Vec < Box < dyn NotifyWork > > > ,
132127 malicious_users : RwLock < HashSet < Address > > ,
133128 immune_users : RwLock < HashSet < Address > > ,
134129}
135130
136131impl Miner {
137- /// Push listener that will handle new jobs
138- pub fn add_work_listener ( & self , notifier : Box < dyn NotifyWork > ) {
139- self . notifiers . write ( ) . push ( notifier) ;
140- }
141-
142132 pub fn new (
143133 options : MinerOptions ,
144134 scheme : & Scheme ,
@@ -167,12 +157,6 @@ impl Miner {
167157 options. mem_pool_fees ,
168158 ) ) ) ;
169159
170- let notifiers: Vec < Box < dyn NotifyWork > > = if options. new_work_notify . is_empty ( ) {
171- Vec :: new ( )
172- } else {
173- vec ! [ Box :: new( WorkPoster :: new( & options. new_work_notify) ) ]
174- } ;
175-
176160 Self {
177161 mem_pool,
178162 transaction_listener : RwLock :: new ( vec ! [ ] ) ,
@@ -188,7 +172,6 @@ impl Miner {
188172 options,
189173 sealing_enabled : AtomicBool :: new ( true ) ,
190174 accounts,
191- notifiers : RwLock :: new ( notifiers) ,
192175 malicious_users : RwLock :: new ( HashSet :: new ( ) ) ,
193176 immune_users : RwLock :: new ( HashSet :: new ( ) ) ,
194177 }
@@ -394,50 +377,29 @@ impl Miner {
394377
395378 /// Prepares work which has to be done to seal.
396379 fn prepare_work ( & self , block : ClosedBlock , original_work_hash : Option < H256 > ) {
397- let ( work, is_new) = {
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 ( ) ) ;
380+ let mut sealing_work = self . sealing_work . lock ( ) ;
381+ let last_work_hash = sealing_work. queue . peek_last_ref ( ) . map ( |pb| pb. block ( ) . header ( ) . hash ( ) ) ;
382+ ctrace ! (
383+ MINER ,
384+ "prepare_work: Checking whether we need to reseal: orig={:?} last={:?}, this={:?}" ,
385+ original_work_hash,
386+ last_work_hash,
387+ block. block( ) . header( ) . hash( )
388+ ) ;
389+ if last_work_hash. map_or ( true , |h| h != block. block ( ) . header ( ) . hash ( ) ) {
400390 ctrace ! (
401391 MINER ,
402- "prepare_work: Checking whether we need to reseal: orig={:?} last={:?}, this={:?}" ,
403- original_work_hash,
404- last_work_hash,
392+ "prepare_work: Pushing a new, refreshed or borrowed pending {}..." ,
405393 block. block( ) . header( ) . hash( )
406394 ) ;
407- let ( work, is_new) = if last_work_hash. map_or ( true , |h| h != block. block ( ) . header ( ) . hash ( ) ) {
408- ctrace ! (
409- MINER ,
410- "prepare_work: Pushing a new, refreshed or borrowed pending {}..." ,
411- block. block( ) . header( ) . hash( )
412- ) ;
413- let pow_hash = * block. block ( ) . header ( ) . hash ( ) ;
414- let number = block. block ( ) . header ( ) . number ( ) ;
415- let score = * block. block ( ) . header ( ) . score ( ) ;
416- let is_new = original_work_hash. map_or ( true , |h| * block. block ( ) . header ( ) . hash ( ) != h) ;
417- sealing_work. queue . push ( block) ;
418- // If push notifications are enabled we assume all work items are used.
419- if !self . notifiers . read ( ) . is_empty ( ) && is_new {
420- sealing_work. queue . use_last_ref ( ) ;
421- }
422- ( Some ( ( pow_hash, score, number) ) , is_new)
423- } else {
424- ( None , false )
425- } ;
426- ctrace ! (
427- MINER ,
428- "prepare_work: leaving (last={:?})" ,
429- sealing_work. queue. peek_last_ref( ) . map( |b| b. block( ) . header( ) . hash( ) )
430- ) ;
431- ( work, is_new)
395+ sealing_work. queue . push ( block) ;
396+ // If push notifications are enabled we assume all work items are used.
432397 } ;
433- if is_new {
434- if let Some ( ( pow_hash, score, _number) ) = work {
435- let target = self . engine . score_to_target ( & score) ;
436- for notifier in self . notifiers . read ( ) . iter ( ) {
437- notifier. notify ( pow_hash, target)
438- }
439- }
440- }
398+ ctrace ! (
399+ MINER ,
400+ "prepare_work: leaving (last={:?})" ,
401+ sealing_work. queue. peek_last_ref( ) . map( |b| b. block( ) . header( ) . hash( ) )
402+ ) ;
441403 }
442404
443405 /// Prepares new block for sealing including top transactions from queue.
0 commit comments