Skip to content

Commit

Permalink
Polish
Browse files Browse the repository at this point in the history
  • Loading branch information
resetius committed Nov 26, 2023
1 parent 75408cf commit 234064c
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 7 deletions.
4 changes: 1 addition & 3 deletions src/raft.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ TRaft::TRaft(int node, const TNodeDict& nodes, const std::shared_ptr<ITimeSource
: Id(node)
, Nodes(nodes)
, TimeSource(ts)
, MinVotes((nodes.size()+1/2))
, MinVotes((nodes.size()+2)/2)
, Npeers(nodes.size())
, Nservers(nodes.size()+1)
, State(std::make_unique<TState>())
Expand Down Expand Up @@ -428,14 +428,12 @@ void TRaft::ApplyResult(ITimeSource::Time now, std::unique_ptr<TResult> result,
v->Send(messageEx);
}
} else {
std::cout << "Send reply to " << messageEx->Dst << "\n";
Nodes[messageEx->Dst]->Send(std::move(messageEx));
}
}
}
if (!result->Messages.empty()) {
for (auto&& m : result->Messages) {
std::cout << "Send append entries to " << m->Dst << "\n";
Nodes[m->Dst]->Send(std::move(m));
}
}
Expand Down
4 changes: 1 addition & 3 deletions src/server.h
Original file line number Diff line number Diff line change
Expand Up @@ -203,12 +203,10 @@ class TRaftServer {

private:
NNet::TSimpleTask InboundServe();
NNet::TSimpleTask InboundConnection(NNet::TSocket socket);
NNet::TSimpleTask Idle();
void DrainNodes();

NNet::TSimpleTask InboundConnection(NNet::TSocket socket);
NNet::TTestTask Connector(std::shared_ptr<INode> node);

NNet::TPoll& Poller;
NNet::TPoll::TSocket Socket;
std::shared_ptr<TRaft> Raft;
Expand Down
2 changes: 1 addition & 1 deletion test/test_raft.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -552,7 +552,7 @@ void test_election_5_nodes(void**) {
raft->Process(req);

assert_int_equal(raft->CurrentStateName(), EState::CANDIDATE);
req->Src = 3;
req->Src = 2;
raft->Process(req);
assert_int_equal(raft->CurrentStateName(), EState::CANDIDATE);

Expand Down

0 comments on commit 234064c

Please sign in to comment.