File tree Expand file tree Collapse file tree 1 file changed +9
-1
lines changed Expand file tree Collapse file tree 1 file changed +9
-1
lines changed Original file line number Diff line number Diff line change @@ -285,8 +285,16 @@ impl HeaderChain {
285285 ///
286286 /// Used in BlockChain::update_best_as_committed().
287287 pub fn update_best_as_committed ( & self , batch : & mut DBTransaction , block_hash : H256 ) {
288- ctrace ! ( HEADERCHAIN , "Update the best block to {}" , block_hash) ;
289288 assert ! ( self . pending_best_header_hash. read( ) . is_none( ) ) ;
289+
290+ let prev_best_header_number = self . best_header ( ) . number ( ) ;
291+ let committed_header_number =
292+ self . block_header_data ( & block_hash) . expect ( "The given hash should exist" ) . number ( ) ;
293+ if prev_best_header_number > committed_header_number {
294+ return
295+ }
296+
297+ ctrace ! ( HEADERCHAIN , "Update the best block to {}" , block_hash) ;
290298 let block_detail = self . block_details ( & block_hash) . expect ( "The given hash should exist" ) ;
291299 let mut new_hashes = HashMap :: new ( ) ;
292300 new_hashes. insert ( block_detail. number , block_hash) ;
You can’t perform that action at this time.
0 commit comments