diff --git a/crates/curp/src/lib.rs b/crates/curp/src/lib.rs index e5e5111b6..b64a408bb 100644 --- a/crates/curp/src/lib.rs +++ b/crates/curp/src/lib.rs @@ -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()) { diff --git a/crates/curp/src/server/mod.rs b/crates/curp/src/server/mod.rs index 10e4b23f4..a1a734fc1 100644 --- a/crates/curp/src/server/mod.rs +++ b/crates/curp/src/server/mod.rs @@ -188,7 +188,6 @@ impl, 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>, diff --git a/crates/curp/src/server/raw_curp/log.rs b/crates/curp/src/server/raw_curp/log.rs index 5d25e3f3b..472b1d90e 100644 --- a/crates/curp/src/server/raw_curp/log.rs +++ b/crates/curp/src/server/raw_curp/log.rs @@ -168,7 +168,7 @@ impl Log { } 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; @@ -197,10 +197,12 @@ impl Log { } // 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 diff --git a/crates/xline-client/src/clients/kv.rs b/crates/xline-client/src/clients/kv.rs index c78e49cba..5da44fd57 100644 --- a/crates/xline-client/src/clients/kv.rs +++ b/crates/xline-client/src/clients/kv.rs @@ -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() diff --git a/crates/xline-client/src/clients/lease.rs b/crates/xline-client/src/clients/lease.rs index 42b7a1e18..06a17b492 100644 --- a/crates/xline-client/src/clients/lease.rs +++ b/crates/xline-client/src/clients/lease.rs @@ -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) diff --git a/crates/xline/src/storage/compact/periodic_compactor.rs b/crates/xline/src/storage/compact/periodic_compactor.rs index 1dd502c84..a88859e0a 100644 --- a/crates/xline/src/storage/compact/periodic_compactor.rs +++ b/crates/xline/src/storage/compact/periodic_compactor.rs @@ -1,5 +1,4 @@ use std::{ - cmp::Ordering, sync::{ atomic::{AtomicBool, Ordering::Relaxed}, Arc, @@ -133,10 +132,7 @@ impl PeriodicCompactor { 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)