File tree Expand file tree Collapse file tree 3 files changed +24
-1
lines changed
core/src/consensus/tendermint Expand file tree Collapse file tree 3 files changed +24
-1
lines changed Original file line number Diff line number Diff line change @@ -404,7 +404,7 @@ impl ConsensusEngine for Tendermint {
404404 }
405405}
406406
407- fn is_term_changed ( header : & Header , parent : & Header , term_seconds : u64 ) -> bool {
407+ pub ( crate ) fn is_term_changed ( header : & Header , parent : & Header , term_seconds : u64 ) -> bool {
408408 if term_seconds == 0 {
409409 return false
410410 }
Original file line number Diff line number Diff line change @@ -1660,6 +1660,28 @@ impl Worker {
16601660 }
16611661 }
16621662
1663+ let mut last_term_end = None ;
1664+ for block_hash in & enacted {
1665+ 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 ( ) ;
1671+ let term_seconds = if let Some ( p) = c. term_common_params ( parent_header. hash ( ) . into ( ) ) {
1672+ p. term_seconds ( )
1673+ } else {
1674+ continue
1675+ } ;
1676+ if super :: engine:: is_term_changed ( & header, & parent_header, term_seconds) {
1677+ last_term_end = Some ( * block_hash) ;
1678+ }
1679+ }
1680+ if let Some ( last_term_end) = last_term_end {
1681+ // TODO: Reduce the snapshot frequency.
1682+ self . snapshot_notify_sender . notify ( last_term_end) ;
1683+ }
1684+
16631685 if let Some ( ( last, rest) ) = imported. split_last ( ) {
16641686 let ( imported, last_proposal_header) = {
16651687 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