File tree Expand file tree Collapse file tree 1 file changed +8
-6
lines changed
core/src/consensus/tendermint Expand file tree Collapse file tree 1 file changed +8
-6
lines changed Original file line number Diff line number Diff line change @@ -52,6 +52,7 @@ use crate::encoded;
5252use crate :: error:: { BlockError , Error } ;
5353use crate :: snapshot_notify:: NotifySender as SnapshotNotifySender ;
5454use crate :: transaction:: { SignedTransaction , UnverifiedTransaction } ;
55+ use crate :: types:: BlockStatus ;
5556use crate :: views:: BlockView ;
5657use crate :: BlockId ;
5758use std:: cell:: Cell ;
@@ -961,7 +962,8 @@ impl Worker {
961962 }
962963
963964 fn on_imported_proposal ( & mut self , proposal : & Header ) {
964- if proposal. number ( ) < 1 {
965+ // NOTE: Only the genesis block and the snapshot target don't have the parent in the blockchain
966+ if self . client ( ) . block_status ( & BlockId :: Hash ( * proposal. parent_hash ( ) ) ) == BlockStatus :: Unknown {
965967 return
966968 }
967969
@@ -1663,11 +1665,11 @@ impl Worker {
16631665 let mut last_term_end = None ;
16641666 for block_hash in & enacted {
16651667 let header = c. block_header ( & BlockId :: Hash ( * block_hash) ) . expect ( "Block is enacted" ) . decode ( ) ;
1666- if header. number ( ) == 0 {
1667- continue
1668- }
1669- let parent_header =
1670- c . block_header ( & BlockId :: Hash ( * header . parent_hash ( ) ) ) . expect ( "Parent block should be enacted" ) . decode ( ) ;
1668+ let parent_header = match c . block_header ( & BlockId :: Hash ( * header. parent_hash ( ) ) ) {
1669+ Some ( h ) => h . decode ( ) ,
1670+ // NOTE: Only the genesis block and the snapshot target don't have the parent in the blockchain
1671+ None => continue ,
1672+ } ;
16711673 let term_seconds = if let Some ( p) = c. term_common_params ( parent_header. hash ( ) . into ( ) ) {
16721674 p. term_seconds ( )
16731675 } else {
You can’t perform that action at this time.
0 commit comments