From d133b6dc469c0bf6f9e7988680d6a0cc3b642586 Mon Sep 17 00:00:00 2001 From: hhwyt Date: Thu, 5 Sep 2024 10:53:45 +0800 Subject: [PATCH] Fix some compilation errors in CI - Adjusted the indentation in documentation comments to ensure proper formatting. - Replaced legacy numeric constants with associated constants. - Removed unnecessary import of legacy numeric constants. Signed-off-by: hhwyt --- src/lib.rs | 24 ++++++++++++------------ src/quorum/majority.rs | 2 +- src/raw_node.rs | 1 + src/storage.rs | 2 +- src/util.rs | 1 - 5 files changed, 15 insertions(+), 15 deletions(-) diff --git a/src/lib.rs b/src/lib.rs index 480c354b..9b9db166 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -201,7 +201,7 @@ The `Ready` state contains quite a bit of information, and you need to check and by one: 1. Check whether `messages` is empty or not. If not, it means that the node will send messages to -other nodes: + other nodes: ```rust # use slog::{Drain, o}; @@ -226,7 +226,7 @@ other nodes: ``` 2. Check whether `snapshot` is empty or not. If not empty, it means that the Raft node has received -a Raft snapshot from the leader and we must apply the snapshot: + a Raft snapshot from the leader and we must apply the snapshot: ```rust # use slog::{Drain, o}; @@ -254,8 +254,8 @@ a Raft snapshot from the leader and we must apply the snapshot: ``` 3. Check whether `committed_entries` is empty or not. If not, it means that there are some newly -committed log entries which you must apply to the state machine. Of course, after applying, you -need to update the applied index and resume `apply` later: + committed log entries which you must apply to the state machine. Of course, after applying, you + need to update the applied index and resume `apply` later: ```rust # use slog::{Drain, o}; @@ -310,7 +310,7 @@ need to update the applied index and resume `apply` later: after restarting, *it may work but potential log loss may also be ignored silently*. 4. Check whether `entries` is empty or not. If not empty, it means that there are newly added -entries but have not been committed yet, we must append the entries to the Raft log: + entries but have not been committed yet, we must append the entries to the Raft log: ```rust # use slog::{Drain, o}; @@ -335,8 +335,8 @@ entries but have not been committed yet, we must append the entries to the Raft ``` 5. Check whether `hs` is empty or not. If not empty, it means that the `HardState` of the node has -changed. For example, the node may vote for a new leader, or the commit index has been increased. -We must persist the changed `HardState`: + changed. For example, the node may vote for a new leader, or the commit index has been increased. + We must persist the changed `HardState`: ```rust # use slog::{Drain, o}; @@ -360,7 +360,7 @@ We must persist the changed `HardState`: ``` 6. Check whether `persisted_messages` is empty or not. If not, it means that the node will send messages to -other nodes after persisting hardstate, entries and snapshot: + other nodes after persisting hardstate, entries and snapshot: ```rust # use slog::{Drain, o}; @@ -385,8 +385,8 @@ other nodes after persisting hardstate, entries and snapshot: ``` 7. Call `advance` to notify that the previous work is completed. Get the return value `LightReady` -and handle its `messages` and `committed_entries` like step 1 and step 3 does. Then call `advance_apply` -to advance the applied index inside. + and handle its `messages` and `committed_entries` like step 1 and step 3 does. Then call `advance_apply` + to advance the applied index inside. ```rust # use slog::{Drain, o}; @@ -470,8 +470,8 @@ This process is a two-phase process, during the midst of it the peer group's lea **two independent, possibly overlapping peer sets**. > **Note:** In order to maintain resiliency guarantees (progress while a majority of both peer sets is -active), it is recommended to wait until the entire peer group has exited the transition phase -before taking old, removed peers offline. + active), it is recommended to wait until the entire peer group has exited the transition phase + before taking old, removed peers offline. */ diff --git a/src/quorum/majority.rs b/src/quorum/majority.rs index 5fcd103e..4ea9292e 100644 --- a/src/quorum/majority.rs +++ b/src/quorum/majority.rs @@ -7,7 +7,7 @@ use std::collections::hash_set::Iter; use std::fmt::Formatter; use std::mem::MaybeUninit; use std::ops::{Deref, DerefMut}; -use std::{cmp, slice, u64}; +use std::{cmp, slice}; /// A set of IDs that uses majority quorums to make decisions. #[derive(Clone, Debug, Default, PartialEq, Eq)] diff --git a/src/raw_node.rs b/src/raw_node.rs index 55b28696..b8adbcc2 100644 --- a/src/raw_node.rs +++ b/src/raw_node.rs @@ -218,6 +218,7 @@ impl Ready { /// MustSync is false if and only if /// 1. no HardState or only its commit is different from before /// 2. no Entries and Snapshot + /// /// If it's false, an asynchronous write of HardState is permissible before calling /// [`RawNode::on_persist_ready`] or [`RawNode::advance`] or its families. #[inline] diff --git a/src/storage.rs b/src/storage.rs index 288501e0..99e02e3a 100644 --- a/src/storage.rs +++ b/src/storage.rs @@ -579,7 +579,7 @@ mod test { new_entry(5, 5), new_entry(6, 6), ]; - let max_u64 = u64::max_value(); + let max_u64 = u64::MAX; let mut tests = vec![ ( 2, diff --git a/src/util.rs b/src/util.rs index 9ad603d2..c4fd582f 100644 --- a/src/util.rs +++ b/src/util.rs @@ -5,7 +5,6 @@ use std::fmt; use std::fmt::Write; -use std::u64; use slog::{OwnedKVList, Record, KV};