@@ -36,7 +36,6 @@ use super::mem_pool::{Error as MemPoolError, MemPool};
36
36
pub use super :: mem_pool_types:: MemPoolFees ;
37
37
use super :: mem_pool_types:: { AccountDetails , MemPoolInput , TxOrigin , TxTimelock } ;
38
38
use super :: sealing_queue:: SealingQueue ;
39
- use super :: work_notify:: { NotifyWork , WorkPoster } ;
40
39
use super :: { MinerService , MinerStatus , TransactionImportResult } ;
41
40
use crate :: account_provider:: { AccountProvider , Error as AccountProviderError } ;
42
41
use crate :: block:: { Block , ClosedBlock , IsBlock } ;
@@ -54,8 +53,6 @@ use std::borrow::Borrow;
54
53
/// Configures the behaviour of the miner.
55
54
#[ derive( Debug , PartialEq ) ]
56
55
pub struct MinerOptions {
57
- /// URLs to notify when there is new work.
58
- pub new_work_notify : Vec < String > ,
59
56
/// Force the miner to reseal, even when nobody has asked for work.
60
57
pub force_sealing : bool ,
61
58
/// Reseal on receipt of new external transactions.
@@ -87,7 +84,6 @@ pub struct MinerOptions {
87
84
impl Default for MinerOptions {
88
85
fn default ( ) -> Self {
89
86
MinerOptions {
90
- new_work_notify : vec ! [ ] ,
91
87
force_sealing : false ,
92
88
reseal_on_external_transaction : true ,
93
89
reseal_on_own_transaction : true ,
@@ -131,17 +127,11 @@ pub struct Miner {
131
127
sealing_enabled : AtomicBool ,
132
128
133
129
accounts : Option < Arc < AccountProvider > > ,
134
- notifiers : RwLock < Vec < Box < dyn NotifyWork > > > ,
135
130
malicious_users : RwLock < HashSet < Address > > ,
136
131
immune_users : RwLock < HashSet < Address > > ,
137
132
}
138
133
139
134
impl 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
-
145
135
pub fn new (
146
136
options : MinerOptions ,
147
137
scheme : & Scheme ,
@@ -170,12 +160,6 @@ impl Miner {
170
160
options. mem_pool_fees ,
171
161
) ) ) ;
172
162
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
-
179
163
Self {
180
164
mem_pool,
181
165
transaction_listener : RwLock :: new ( vec ! [ ] ) ,
@@ -191,7 +175,6 @@ impl Miner {
191
175
options,
192
176
sealing_enabled : AtomicBool :: new ( true ) ,
193
177
accounts,
194
- notifiers : RwLock :: new ( notifiers) ,
195
178
malicious_users : RwLock :: new ( HashSet :: new ( ) ) ,
196
179
immune_users : RwLock :: new ( HashSet :: new ( ) ) ,
197
180
}
@@ -412,50 +395,29 @@ impl Miner {
412
395
413
396
/// Prepares work which has to be done to seal.
414
397
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 ( ) ) {
418
408
ctrace ! (
419
409
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 {}..." ,
423
411
block. block( ) . header( ) . hash( )
424
412
) ;
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.
450
415
} ;
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
+ ) ;
459
421
}
460
422
461
423
/// Prepares new block for sealing including top transactions from queue.
0 commit comments