@@ -371,26 +371,52 @@ impl Importer {
371
371
imported. len ( )
372
372
}
373
373
374
- pub fn import_bootstrap_block < ' a > ( & ' a self , block : & ' a Block , client : & Client , _importer_lock : & MutexGuard < ( ) > ) {
374
+ pub fn import_trusted_header < ' a > ( & ' a self , header : & ' a Header , client : & Client , _importer_lock : & MutexGuard < ( ) > ) {
375
+ let hash = header. hash ( ) ;
376
+ ctrace ! ( CLIENT , "Importing trusted header #{}-{:?}" , header. number( ) , hash) ;
377
+
378
+ {
379
+ let chain = client. block_chain ( ) ;
380
+ let mut batch = DBTransaction :: new ( ) ;
381
+ chain. insert_floating_header ( & mut batch, & HeaderView :: new ( & header. rlp_bytes ( ) ) ) ;
382
+ client. db ( ) . write_buffered ( batch) ;
383
+ chain. commit ( ) ;
384
+ }
385
+ client. new_headers ( & [ hash] , & [ ] , & [ ] , & [ ] , & [ ] , 0 , None ) ;
386
+
387
+ client. db ( ) . flush ( ) . expect ( "DB flush failed." ) ;
388
+ }
389
+
390
+ pub fn import_trusted_block < ' a > ( & ' a self , block : & ' a Block , client : & Client , importer_lock : & MutexGuard < ( ) > ) {
375
391
let header = & block. header ;
376
392
let hash = header. hash ( ) ;
377
- ctrace ! ( CLIENT , "Importing bootstrap block #{}-{:?}" , header. number( ) , hash) ;
393
+ ctrace ! ( CLIENT , "Importing trusted block #{}-{:?}" , header. number( ) , hash) ;
378
394
395
+ self . import_trusted_header ( header, client, importer_lock) ;
379
396
let start = Instant :: now ( ) ;
380
397
{
381
398
let chain = client. block_chain ( ) ;
382
399
let mut batch = DBTransaction :: new ( ) ;
383
- chain. insert_bootstrap_block ( & mut batch, & block. rlp_bytes ( & Seal :: With ) ) ;
400
+ chain. insert_floating_block ( & mut batch, & block. rlp_bytes ( & Seal :: With ) ) ;
384
401
client. db ( ) . write_buffered ( batch) ;
385
402
chain. commit ( ) ;
386
403
}
387
404
let duration = {
388
405
let elapsed = start. elapsed ( ) ;
389
406
elapsed. as_secs ( ) * 1_000_000_000 + u64:: from ( elapsed. subsec_nanos ( ) )
390
407
} ;
391
- client. new_headers ( & [ hash] , & [ ] , & [ hash] , & [ ] , & [ ] , 0 , Some ( hash) ) ;
392
- self . miner . chain_new_blocks ( client, & [ hash] , & [ ] , & [ hash] , & [ ] ) ;
393
- client. new_blocks ( & [ hash] , & [ ] , & [ hash] , & [ ] , & [ ] , duration) ;
408
+ self . miner . chain_new_blocks ( client, & [ hash] , & [ ] , & [ ] , & [ ] ) ;
409
+ client. new_blocks ( & [ hash] , & [ ] , & [ ] , & [ ] , & [ ] , duration) ;
410
+
411
+ client. db ( ) . flush ( ) . expect ( "DB flush failed." ) ;
412
+ }
413
+
414
+ pub fn force_update_best_block ( & self , hash : & BlockHash , client : & Client ) {
415
+ let chain = client. block_chain ( ) ;
416
+ let mut batch = DBTransaction :: new ( ) ;
417
+ chain. force_update_best_block ( & mut batch, hash) ;
418
+ client. db ( ) . write_buffered ( batch) ;
419
+ chain. commit ( ) ;
394
420
395
421
client. db ( ) . flush ( ) . expect ( "DB flush failed." ) ;
396
422
}
0 commit comments