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 @@ -325,7 +325,7 @@ impl ConsensusEngine for Tendermint {
325325 }
326326}
327327
328- fn is_term_changed ( header : & Header , parent : & Header , term_seconds : u64 ) -> bool {
328+ pub ( crate ) fn is_term_changed ( header : & Header , parent : & Header , term_seconds : u64 ) -> bool {
329329 if term_seconds == 0 {
330330 return false
331331 }
Original file line number Diff line number Diff line change @@ -1637,6 +1637,28 @@ impl Worker {
16371637 }
16381638 }
16391639
1640+ let mut last_term_end = None ;
1641+ for block_hash in & enacted {
1642+ let header = c. block_header ( & BlockId :: Hash ( * block_hash) ) . expect ( "Block is enacted" ) . decode ( ) ;
1643+ if header. number ( ) == 0 {
1644+ continue
1645+ }
1646+ let parent_header =
1647+ c. block_header ( & BlockId :: Hash ( * header. parent_hash ( ) ) ) . expect ( "Parent block should be enacted" ) . decode ( ) ;
1648+ let term_seconds = if let Some ( p) = c. term_common_params ( parent_header. hash ( ) . into ( ) ) {
1649+ p. term_seconds ( )
1650+ } else {
1651+ continue
1652+ } ;
1653+ if super :: engine:: is_term_changed ( & header, & parent_header, term_seconds) {
1654+ last_term_end = Some ( * block_hash) ;
1655+ }
1656+ }
1657+ if let Some ( last_term_end) = last_term_end {
1658+ // TODO: Reduce the snapshot frequency.
1659+ self . snapshot_notify_sender . notify ( last_term_end) ;
1660+ }
1661+
16401662 if let Some ( ( last, rest) ) = imported. split_last ( ) {
16411663 let ( imported, last_proposal_header) = {
16421664 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