File tree Expand file tree Collapse file tree 2 files changed +23
-0
lines changed
core/src/consensus/tendermint Expand file tree Collapse file tree 2 files changed +23
-0
lines changed Original file line number Diff line number Diff line change @@ -1657,6 +1657,28 @@ impl Worker {
16571657 }
16581658 }
16591659
1660+ let mut last_term_end = None ;
1661+ for block_hash in & enacted {
1662+ 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 ( ) ;
1668+ let term_common_params = if let Some ( p) = c. term_common_params ( parent_header. hash ( ) . into ( ) ) {
1669+ p
1670+ } else {
1671+ continue
1672+ } ;
1673+ if super :: engine:: block_number_if_term_changed ( & header, & parent_header, & term_common_params) . is_some ( ) {
1674+ last_term_end = Some ( * block_hash) ;
1675+ }
1676+ }
1677+ if let Some ( last_term_end) = last_term_end {
1678+ // TODO: Reduce the snapshot frequency.
1679+ self . snapshot_notify_sender . notify ( last_term_end) ;
1680+ }
1681+
16601682 if let Some ( ( last, rest) ) = imported. split_last ( ) {
16611683 let ( imported, last_proposal_header) = {
16621684 let header =
Original file line number Diff line number Diff line change @@ -57,6 +57,7 @@ impl Service {
5757 } else {
5858 cinfo ! ( SYNC , "Snapshot is ready for block: {}" , block_hash)
5959 }
60+ // TODO: Prune old snapshots
6061 }
6162 cinfo ! ( SYNC , "Snapshot service is stopped" )
6263 } ) ;
You can’t perform that action at this time.
0 commit comments