Skip to content

Commit

Permalink
fix(client): remove redundant, add missing and other trivial change
Browse files Browse the repository at this point in the history
Signed-off-by: lxl66566 <[email protected]>

chore(curp): add a missing testcase to lib.rs

Signed-off-by: lxl66566 <[email protected]>

chore(raw_curp): trivial change to functional expression

Signed-off-by: lxl66566 <[email protected]>
  • Loading branch information
lxl66566 committed Oct 14, 2024
1 parent 933092b commit f4684b5
Show file tree
Hide file tree
Showing 6 changed files with 9 additions and 13 deletions.
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

0 comments on commit f4684b5

Please sign in to comment.