Skip to content

Commit

Permalink
Bugfix
Browse files Browse the repository at this point in the history
  • Loading branch information
resetius committed Nov 29, 2023
1 parent 0945107 commit a21499a
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/raft.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -151,7 +151,7 @@ std::unique_ptr<TResult> TRaft::OnRequestVote(TMessageHolder<TRequestVoteRespons
}

std::unique_ptr<TResult> TRaft::OnAppendEntries(TMessageHolder<TAppendEntriesRequest> message) {
if (message->Term < State->CurrentTerm) {
if (message->Term > State->CurrentTerm) {
auto reply = NewHoldedMessage<TAppendEntriesResponse>();
reply->Src = Id;
reply->Dst = message->Src;
Expand Down Expand Up @@ -239,7 +239,7 @@ TMessageHolder<TRequestVoteRequest> TRaft::CreateVote() {
auto mes = NewHoldedMessage(
TMessageEx {.Src = Id, .Dst = 0, .Term = State->CurrentTerm+1},
TRequestVoteRequest {
.LastLogIndex = State->Log.size(),
.LastLogIndex = State->Log.size(),
.LastLogTerm = State->Log.empty() ? 0 : State->Log.back()->Term,
.CandidateId = Id,
});
Expand Down

0 comments on commit a21499a

Please sign in to comment.