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 ;
@@ -958,7 +959,8 @@ impl Worker {
958959 }
959960
960961 pub fn on_imported_proposal ( & mut self , proposal : & Header ) {
961- if proposal. number ( ) < 1 {
962+ // NOTE: Only the genesis block and the snapshot target don't have the parent in the blockchain
963+ if self . client ( ) . block_status ( & BlockId :: Hash ( * proposal. parent_hash ( ) ) ) == BlockStatus :: Unknown {
962964 return
963965 }
964966
@@ -1660,11 +1662,11 @@ impl Worker {
16601662 let mut last_term_end = None ;
16611663 for block_hash in & enacted {
16621664 let header = c. block_header ( & BlockId :: Hash ( * block_hash) ) . expect ( "Block is enacted" ) . decode ( ) ;
1663- if header. number ( ) == 0 {
1664- continue
1665- }
1666- let parent_header =
1667- c . block_header ( & BlockId :: Hash ( * header . parent_hash ( ) ) ) . expect ( "Parent block should be enacted" ) . decode ( ) ;
1665+ let parent_header = match c . block_header ( & BlockId :: Hash ( * header. parent_hash ( ) ) ) {
1666+ Some ( h ) => h . decode ( ) ,
1667+ // NOTE: Only the genesis block and the snapshot target don't have the parent in the blockchain
1668+ None => continue ,
1669+ } ;
16681670 let term_common_params = if let Some ( p) = c. term_common_params ( parent_header. hash ( ) . into ( ) ) {
16691671 p
16701672 } else {
You can’t perform that action at this time.
0 commit comments