@@ -148,7 +148,7 @@ pub struct RaftCore<C: RaftTypeConfig, N: RaftNetworkFactory<C>, S: RaftStorage<
148
148
pub ( crate ) leader_data : Option < LeaderData < C > > ,
149
149
150
150
/// The node's current snapshot state.
151
- pub ( crate ) snapshot_state : Option < SnapshotState < S :: SnapshotData > > ,
151
+ pub ( crate ) snapshot_state : Option < SnapshotState < C , S :: SnapshotData > > ,
152
152
153
153
/// The time to elect if a follower does not receive any append-entry message.
154
154
pub ( crate ) next_election_time : VoteWiseTime < C :: NodeId > ,
@@ -252,7 +252,7 @@ impl<C: RaftTypeConfig, N: RaftNetworkFactory<C>, S: RaftStorage<C>> RaftCore<C,
252
252
253
253
// Fetch the most recent snapshot in the system.
254
254
if let Some ( snapshot) = self . storage . get_current_snapshot ( ) . await ? {
255
- self . engine . snapshot_last_log_id = Some ( snapshot. meta . last_log_id ) ;
255
+ self . engine . snapshot_last_log_id = snapshot. meta . last_log_id ;
256
256
self . engine . metrics_flags . set_data_changed ( ) ;
257
257
}
258
258
@@ -836,7 +836,7 @@ impl<C: RaftTypeConfig, N: RaftNetworkFactory<C>, S: RaftStorage<C>> RaftCore<C,
836
836
#[ tracing:: instrument( level = "trace" , skip( self ) ) ]
837
837
pub ( crate ) fn update_snapshot_state ( & mut self , update : SnapshotUpdate < C :: NodeId > ) {
838
838
if let SnapshotUpdate :: SnapshotComplete ( log_id) = update {
839
- self . engine . snapshot_last_log_id = Some ( log_id) ;
839
+ self . engine . snapshot_last_log_id = log_id;
840
840
self . engine . metrics_flags . set_data_changed ( ) ;
841
841
}
842
842
// If snapshot state is anything other than streaming, then drop it.
@@ -894,7 +894,7 @@ impl<C: RaftTypeConfig, N: RaftNetworkFactory<C>, S: RaftStorage<C>> RaftCore<C,
894
894
update : SnapshotUpdate :: SnapshotComplete ( snapshot. meta . last_log_id ) ,
895
895
} ) ;
896
896
// This will always succeed.
897
- let _ = chan_tx. send ( snapshot. meta . last_log_id . index ) ;
897
+ let _ = chan_tx. send ( snapshot. meta . last_log_id ) ;
898
898
}
899
899
Err ( err) => {
900
900
tracing:: error!( { error=%err} , "error while generating snapshot" ) ;
@@ -1514,16 +1514,16 @@ impl<C: RaftTypeConfig, N: RaftNetworkFactory<C>, S: RaftStorage<C>> RaftCore<C,
1514
1514
let current_snapshot_opt = self . storage . get_current_snapshot ( ) . await ?;
1515
1515
1516
1516
if let Some ( snapshot) = current_snapshot_opt {
1517
- if let Some ( must_inc ) = must_include {
1518
- if snapshot. meta . last_log_id >= must_inc {
1517
+ if must_include . is_some ( ) {
1518
+ if snapshot. meta . last_log_id >= must_include {
1519
1519
let _ = tx. send ( snapshot) ;
1520
1520
return Ok ( ( ) ) ;
1521
1521
}
1522
1522
} else {
1523
1523
// If snapshot exists, ensure its distance from the leader's last log index is <= half
1524
1524
// of the configured snapshot threshold, else create a new snapshot.
1525
1525
if snapshot_is_within_half_of_threshold (
1526
- & snapshot. meta . last_log_id . index ,
1526
+ & snapshot. meta . last_log_id . unwrap_or_default ( ) . index ,
1527
1527
& self . engine . state . last_log_id ( ) . unwrap_or_default ( ) . index ,
1528
1528
& threshold,
1529
1529
) {
0 commit comments