src/raft: cargo clippy

This commit is contained in:
ghassmo
2022-04-24 17:07:37 +03:00
parent 56e4f88133
commit 2392387d69

View File

@@ -190,12 +190,11 @@ impl<T: Decodable + Encodable + Clone> Raft<T> {
}
loop {
let timeout: Duration;
if self.role == Role::Leader {
timeout = Duration::from_millis(HEARTBEATTIMEOUT);
let timeout: Duration = if self.role == Role::Leader {
Duration::from_millis(HEARTBEATTIMEOUT)
} else {
timeout = Duration::from_millis(rng.gen_range(0..200) + TIMEOUT);
}
Duration::from_millis(rng.gen_range(0..200) + TIMEOUT)
};
let result: Result<()>;
@@ -286,9 +285,9 @@ impl<T: Decodable + Encodable + Clone> Raft<T> {
}
debug!(
target: "raft",
"{} {:?} receive msg id: {} recipient_id: {:?} method: {:?} ",
self.id.is_some(), self.role, msg.id, &msg.recipient_id.is_some(), &msg.method
target: "raft",
"{} {:?} receive msg id: {} recipient_id: {:?} method: {:?} ",
self.id.is_some(), self.role, msg.id, &msg.recipient_id.is_some(), &msg.method
);
Ok(())
}
@@ -301,9 +300,9 @@ impl<T: Decodable + Encodable + Clone> Raft<T> {
let random_id = OsRng.next_u32();
debug!(
target: "raft",
"{} {:?} send a msg id: {} recipient_id: {:?} method: {:?} ",
self.id.is_some(), self.role, random_id, &recipient_id.is_some(), &method
target: "raft",
"{} {:?} send a msg id: {} recipient_id: {:?} method: {:?} ",
self.id.is_some(), self.role, random_id, &recipient_id.is_some(), &method
);
let net_msg = NetMsg { id: random_id, recipient_id, payload: payload.to_vec(), method };