Skip to content

Commit

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

std::unique_ptr<TResult> TRaft::OnAppendEntries(TMessageHolder<TAppendEntriesRequest> message) {
if (message->Term > State->CurrentTerm) {
auto reply = NewHoldedMessage<TAppendEntriesResponse>();
reply->Src = Id;
reply->Dst = message->Src;
reply->Term = State->CurrentTerm;
reply->Success = false;
reply->MatchIndex = 0;
auto reply = NewHoldedMessage(
TMessageEx {
.Src = Id,
.Dst = message->Src,
.Term = State->CurrentTerm,
},
TAppendEntriesResponse {
.MatchIndex = 0,
.Success = false,
});
return std::make_unique<TResult>(TResult {
.UpdateLastTime = true,
.Message = reply,
Expand Down

0 comments on commit fda8895

Please sign in to comment.