Skip to content

Commit

Permalink
rebase && format
Browse files Browse the repository at this point in the history
  • Loading branch information
csmoe committed May 11, 2018
1 parent 1080163 commit c74e0af
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 9 deletions.
9 changes: 5 additions & 4 deletions src/raft.rs
Original file line number Diff line number Diff line change
Expand Up @@ -938,9 +938,9 @@ impl<T: Storage> Raft<T> {
}
}
} else if m.get_term() < self.term {
if (self.check_quorum || self.pre_vote) &&
(m.get_msg_type() == MessageType::MsgHeartbeat ||
m.get_msg_type() == MessageType::MsgAppend)
if (self.check_quorum || self.pre_vote)
&& (m.get_msg_type() == MessageType::MsgHeartbeat
|| m.get_msg_type() == MessageType::MsgAppend)
{
// We have received messages from a leader at a lower term. It is possible
// that these messages were simply delayed in the network, but this could
Expand Down Expand Up @@ -982,7 +982,8 @@ impl<T: Storage> Raft<T> {
self.term,
);

let mut to_send = new_message(m.get_from(), MessageType::MsgRequestPreVoteResponse, None);
let mut to_send =
new_message(m.get_from(), MessageType::MsgRequestPreVoteResponse, None);
to_send.set_term(self.term);
to_send.set_reject(true);
self.send(to_send);
Expand Down
7 changes: 2 additions & 5 deletions tests/cases/test_raft.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3987,9 +3987,7 @@ fn new_prevote_migration_cluster() -> Network {

// Cause a network partition to isolate n3.
nt.isolate(3);
nt.send(vec![
new_message(1, 1, MessageType::MsgPropose, 1)
]);
nt.send(vec![new_message(1, 1, MessageType::MsgPropose, 1)]);

nt.send(vec![new_message(3, 3, MessageType::MsgHup, 0)]);
nt.send(vec![new_message(3, 3, MessageType::MsgHup, 0)]);
Expand Down Expand Up @@ -4042,8 +4040,7 @@ fn test_prevote_migration_can_complete_election() {

// Do we have a leader?
assert!(
(nt.peers[&2].state == StateRole::Leader) ||
(nt.peers[&3].state == StateRole::Follower)
(nt.peers[&2].state == StateRole::Leader) || (nt.peers[&3].state == StateRole::Follower)
);
}

Expand Down

0 comments on commit c74e0af

Please sign in to comment.