File tree Expand file tree Collapse file tree 1 file changed +13
-3
lines changed
Expand file tree Collapse file tree 1 file changed +13
-3
lines changed Original file line number Diff line number Diff line change @@ -21,7 +21,7 @@ use std::time::Instant;
2121
2222use cio:: IoChannel ;
2323use kvdb:: DBTransaction ;
24- use parking_lot:: Mutex ;
24+ use parking_lot:: { Mutex , MutexGuard } ;
2525use primitives:: H256 ;
2626use rlp:: Encodable ;
2727
@@ -365,14 +365,24 @@ impl Importer {
365365 /// This is triggered by a message coming from a header queue when the header is ready for insertion
366366 pub fn import_verified_headers ( & self , client : & Client ) -> usize {
367367 let max_headers_to_import = 256 ;
368+ let lock = self . import_lock . lock ( ) ;
369+ let headers = self . header_queue . drain ( max_headers_to_import) ;
370+ self . import_headers ( & headers, client, & lock)
371+ }
368372
369- let _lock = self . import_lock . lock ( ) ;
373+ fn import_headers < ' a > (
374+ & ' a self ,
375+ headers : impl IntoIterator < Item = & ' a Header > ,
376+ client : & Client ,
377+ _importer_lock : & MutexGuard < ( ) > ,
378+ ) -> usize {
370379 let prev_best_proposal_header_hash = client. block_chain ( ) . best_proposal_header ( ) . hash ( ) ;
371380
372381 let mut bad = HashSet :: new ( ) ;
373382 let mut imported = Vec :: new ( ) ;
374383 let mut routes = Vec :: new ( ) ;
375- for header in self . header_queue . drain ( max_headers_to_import) {
384+
385+ for header in headers {
376386 let hash = header. hash ( ) ;
377387 ctrace ! ( CLIENT , "Importing header {}" , header. number( ) ) ;
378388
You can’t perform that action at this time.
0 commit comments