Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: code fixing, remove redundant and add missing #880

Merged
merged 1 commit into from
Oct 15, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions crates/curp/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -247,6 +247,7 @@ mod test {
(3, 2, 4),
(4, 3, 5),
(4, 3, 6),
(6, 4, 8),
];

for (node_cnt, expected) in nodes.into_iter().zip(expected_res.into_iter()) {
Expand Down
1 change: 0 additions & 1 deletion crates/curp/src/server/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -188,7 +188,6 @@ impl<C: Command, CE: CommandExecutor<C>, RC: RoleChange> crate::rpc::Protocol fo
}

#[instrument(skip_all, name = "lease_keep_alive")]
#[allow(clippy::unimplemented)]
async fn lease_keep_alive(
&self,
request: tonic::Request<tonic::Streaming<LeaseKeepAliveMsg>>,
Expand Down
12 changes: 7 additions & 5 deletions crates/curp/src/server/raw_curp/log.rs
Original file line number Diff line number Diff line change
Expand Up @@ -168,7 +168,7 @@ impl<C: Command> Log<C> {
}
let end = self.li_to_pi(self.batch_end[self.first_idx_in_cur_batch - 1]);
match end.cmp(&last_index) {
// All the `batch_end[i]` lager than `len - 1` should be reset to zero
// All the `batch_end[i]` larger than `len - 1` should be reset to zero
Ordering::Greater => {
self.batch_end[self.first_idx_in_cur_batch - 1] = 0;
self.first_idx_in_cur_batch -= 1;
Expand Down Expand Up @@ -197,10 +197,12 @@ impl<C: Command> Log<C> {
}

// recalculate the `cur_batch_size`
self.cur_batch_size = 0;
for entry in self.entries.iter().skip(self.first_idx_in_cur_batch) {
self.cur_batch_size += entry.size;
}
self.cur_batch_size = self
.entries
.iter()
.skip(self.first_idx_in_cur_batch)
.map(|entry| entry.size)
.sum();
}

/// push a log entry into the back of queue
Expand Down
1 change: 0 additions & 1 deletion crates/xline-client/src/clients/kv.rs
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,6 @@ impl Debug for KvClient {
#[inline]
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
f.debug_struct("KvClient")
.field("kv_client", &self.kv_client)
.field("kv_client", &self.kv_client)
.field("token", &self.token)
.finish()
Expand Down
1 change: 0 additions & 1 deletion crates/xline-client/src/clients/lease.rs
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,6 @@ impl Debug for LeaseClient {
#[inline]
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
f.debug_struct("LeaseClient")
.field("lease_client", &self.lease_client)
.field("lease_client", &self.lease_client)
.field("token", &self.token)
.field("id_gen", &self.id_gen)
Expand Down
6 changes: 1 addition & 5 deletions crates/xline/src/storage/compact/periodic_compactor.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
use std::{
cmp::Ordering,
sync::{
atomic::{AtomicBool, Ordering::Relaxed},
Arc,
Expand Down Expand Up @@ -133,10 +132,7 @@ impl<C: Compactable> PeriodicCompactor<C> {
fn sample_config(period: Duration) -> (Duration, usize) {
/// one hour duration
const ONEHOUR: Duration = Duration::from_secs(3600);
let base_interval = match period.cmp(&ONEHOUR) {
Ordering::Less => period,
Ordering::Equal | Ordering::Greater => ONEHOUR,
};
let base_interval = period.min(ONEHOUR);
let divisor = 10;
let check_interval = base_interval
.checked_div(divisor)
Expand Down
Loading