Skip to content

Commit

Permalink
chore: update comments and remove unecessary codes
Browse files Browse the repository at this point in the history
Signed-off-by: themanforfree <[email protected]>
  • Loading branch information
themanforfree committed Oct 11, 2023
1 parent a4f9fdc commit ed5629d
Show file tree
Hide file tree
Showing 5 changed files with 11 additions and 12 deletions.
11 changes: 7 additions & 4 deletions curp/src/server/cmd_board.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
use std::{collections::HashMap, sync::Arc};
use std::{
collections::{HashMap, HashSet},
sync::Arc,
};

use event_listener::{Event, EventListener};
use indexmap::{IndexMap, IndexSet};
Expand All @@ -21,8 +24,8 @@ pub(super) struct CommandBoard<C: Command> {
shutdown_notifier: Event,
/// Store all notifiers for conf change results
conf_notifier: HashMap<ProposeId, Event>,
/// Store all conf change results
pub(super) conf_buffer: IndexSet<ProposeId>,
/// Store all conf change propose ids
pub(super) conf_buffer: HashSet<ProposeId>,
/// The cmd has been received before, this is used for dedup
pub(super) sync: IndexSet<ProposeId>,
/// Store all execution results
Expand All @@ -42,7 +45,7 @@ impl<C: Command> CommandBoard<C> {
er_buffer: IndexMap::new(),
asr_buffer: IndexMap::new(),
conf_notifier: HashMap::new(),
conf_buffer: IndexSet::new(),
conf_buffer: HashSet::new(),
}
}

Expand Down
7 changes: 3 additions & 4 deletions curp/src/server/cmd_worker/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -165,10 +165,9 @@ async fn worker_as<
error!("failed to set last_applied, {e}");
return false;
}
let change = conf_change
.changes()
.first()
.unwrap_or_else(|| unreachable!("conf change should always have at one change"));
let change = conf_change.changes().first().unwrap_or_else(|| {
unreachable!("conf change should always have at least one change")
});
let shutdown_self =
change.change_type() == ConfChangeType::Remove && change.node_id == id;
cb.write().insert_conf(entry.id());
Expand Down
1 change: 0 additions & 1 deletion curp/src/server/raw_curp/log.rs
Original file line number Diff line number Diff line change
Expand Up @@ -205,7 +205,6 @@ impl<C: Command> Debug for Log<C> {
}
}

// TODO
/// Conf change entries type
type ConfChangeEntries<C> = Vec<Arc<LogEntry<C>>>;
/// Fallback indexes type
Expand Down
3 changes: 1 addition & 2 deletions curp/src/server/raw_curp/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1272,8 +1272,7 @@ impl<C: 'static + Command, RC: RoleChange + 'static> RawCurp<C, RC> {
Ok(())
}

/// Switch to a new config and return true if self node is removed
/// and return old member infos for fallback
/// Switch to a new config and return old member infos for fallback
#[allow(clippy::unimplemented)] // TODO: remove this when learner is implemented
fn switch_config(&self, conf_change: ConfChange) -> (Vec<String>, String, bool) {
let node_id = conf_change.node_id;
Expand Down
1 change: 0 additions & 1 deletion curp/tests/server.rs
Original file line number Diff line number Diff line change
Expand Up @@ -374,7 +374,6 @@ async fn propose_remove_node_should_failed_when_cluster_nodes_equals_to_three()
let changes = vec![ConfChange::remove(node_id)];
let conf_change = ProposeConfChangeRequest::new(id, changes);
let res = client.propose_conf_change(conf_change).await.unwrap();
println!("{res:?}");
assert!(matches!(res, Err(ConfChangeError::InvalidConfig(()))));
}

Expand Down

0 comments on commit ed5629d

Please sign in to comment.