From fda8895e9475835c373595075da36a71c6352a48 Mon Sep 17 00:00:00 2001 From: Alexey Ozeritskiy Date: Wed, 29 Nov 2023 19:08:29 +0100 Subject: [PATCH] Simplify --- src/raft.cpp | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/src/raft.cpp b/src/raft.cpp index 15389a6..4c4ba1f 100644 --- a/src/raft.cpp +++ b/src/raft.cpp @@ -152,12 +152,16 @@ std::unique_ptr TRaft::OnRequestVote(TMessageHolder TRaft::OnAppendEntries(TMessageHolder message) { if (message->Term > State->CurrentTerm) { - auto reply = NewHoldedMessage(); - 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 { .UpdateLastTime = true, .Message = reply,