Skip to content

Commit

Permalink
better naming and docs, remove unnecessary macro test, clippy fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
haraldng committed May 22, 2024
1 parent 192564d commit 5643fbd
Show file tree
Hide file tree
Showing 7 changed files with 11 additions and 26 deletions.
2 changes: 1 addition & 1 deletion omnipaxos/src/storage/internal_storage.rs
Original file line number Diff line number Diff line change
Expand Up @@ -500,7 +500,7 @@ where
} else if ss.is_none() && self.state_cache.stopsign.is_some() {
self.state_cache.accepted_idx -= 1;
}
self.state_cache.stopsign = ss.clone();
self.state_cache.stopsign.clone_from(&ss);
self.storage.set_stopsign(ss)?;
Ok(self.state_cache.accepted_idx)
}
Expand Down
2 changes: 1 addition & 1 deletion omnipaxos/src/storage/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -163,7 +163,7 @@ where
/// If entries **do not exist for the complete interval**, an empty Vector should be returned.
fn get_entries(&self, from: usize, to: usize) -> StorageResult<Vec<T>>;

/// Returns the current length of the log.
/// Returns the current length of the log (without the trimmed/snapshotted entries).
fn get_log_len(&self) -> StorageResult<usize>;

/// Returns the suffix of entries in the log from index `from` (inclusive).
Expand Down
2 changes: 1 addition & 1 deletion omnipaxos/tests/snapshot_test.rs
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,7 @@ fn double_snapshot_test() {
}

fn check_snapshot(
vec_proposals: &Vec<Value>,
vec_proposals: &[Value],
snapshot_idx: usize,
node: Arc<Component<OmniPaxosComponent>>,
) {
Expand Down
6 changes: 1 addition & 5 deletions omnipaxos/tests/trim_test.rs
Original file line number Diff line number Diff line change
Expand Up @@ -133,11 +133,7 @@ fn double_trim_test() {
};
}

fn check_trim(
vec_proposals: &Vec<Value>,
trim_idx: usize,
node: Arc<Component<OmniPaxosComponent>>,
) {
fn check_trim(vec_proposals: &[Value], trim_idx: usize, node: Arc<Component<OmniPaxosComponent>>) {
let num_proposals = vec_proposals.len();
node.on_definition(|x| {
let op = &x.paxos;
Expand Down
2 changes: 1 addition & 1 deletion omnipaxos/tests/utils.rs
Original file line number Diff line number Diff line change
Expand Up @@ -852,7 +852,7 @@ pub mod omnireplica {
}

pub fn is_connected_to(&self, pid: &NodeId) -> bool {
self.peer_disconnections.get(pid).is_none()
!self.peer_disconnections.contains(pid)
}

fn answer_election_future(&mut self, l: Ballot) {
Expand Down
11 changes: 0 additions & 11 deletions omnipaxos_macros/tests/derive_test.rs
Original file line number Diff line number Diff line change
@@ -1,14 +1,3 @@
#[test]
fn derive_entry_test() {
use omnipaxos::macros::Entry;

#[derive(Clone, Debug, Entry)]
struct TestEntry {
pub _field1: u64,
pub _field2: String,
}
}

#[test]
fn build_op_test() {
use omnipaxos::{macros::Entry, ClusterConfig, OmniPaxos, OmniPaxosConfig, ServerConfig};
Expand Down
12 changes: 6 additions & 6 deletions omnipaxos_storage/src/persistent_storage.rs
Original file line number Diff line number Diff line change
Expand Up @@ -247,15 +247,15 @@ where
Ok(())
}

fn batch_set_stopsign(&mut self, s: Option<StopSign>) -> StorageResult<()> {
let stopsign = bincode::serialize(&s)?;
fn batch_set_stopsign(&mut self, ss: Option<StopSign>) -> StorageResult<()> {
let stopsign = bincode::serialize(&ss)?;
self.write_batch.put(STOPSIGN, stopsign);
Ok(())
}

fn batch_set_snapshot(&mut self, snapshot: Option<T::Snapshot>) -> StorageResult<()> {
let stopsign = bincode::serialize(&snapshot)?;
self.write_batch.put(SNAPSHOT, stopsign);
let s = bincode::serialize(&snapshot)?;
self.write_batch.put(SNAPSHOT, s);
Ok(())
}
}
Expand Down Expand Up @@ -441,8 +441,8 @@ where
}

fn set_snapshot(&mut self, snapshot: Option<T::Snapshot>) -> StorageResult<()> {
let stopsign = bincode::serialize(&snapshot)?;
self.db.put(SNAPSHOT, stopsign)?;
let s = bincode::serialize(&snapshot)?;
self.db.put(SNAPSHOT, s)?;
Ok(())
}

Expand Down

0 comments on commit 5643fbd

Please sign in to comment.