Can only BeginBallot once
This commit is contained in:
parent
60772b4db1
commit
bd6ce7db3b
@ -25,6 +25,7 @@ namespace paxos
|
||||
|
||||
auto buffer = connection_->get_buffer_out();
|
||||
std::string response = buffer.to_string();
|
||||
log("Sending a message: ", blue);
|
||||
|
||||
log(response, white);
|
||||
ssize_t write = 0;
|
||||
@ -81,6 +82,7 @@ namespace paxos
|
||||
std::string ip = legislator->config_.ip;
|
||||
std::string port = legislator->config_.port;
|
||||
std::string name = legislator->config_.name;
|
||||
message.add_header("receiver", name);
|
||||
shared_socket socket;
|
||||
try
|
||||
{
|
||||
@ -96,6 +98,5 @@ namespace paxos
|
||||
message.fill_buffer(connection->get_buffer_out());
|
||||
|
||||
event_register.register_event<SendEW>(connection);
|
||||
log("Sending a message to " + name + ": ", blue);
|
||||
}
|
||||
}
|
||||
|
@ -91,7 +91,9 @@ namespace paxos
|
||||
int vote_ballot_id = std::stoi(vote_ballot_id_str);
|
||||
int vote_decree = std::stoi(*message.get_header("decree"));
|
||||
|
||||
if (ballot != ledger.last_tried())
|
||||
unsigned int nb_legislators = legislators.size();
|
||||
if (ballot != ledger.last_tried()
|
||||
|| quorum_previous_votes.size() > nb_legislators / 2)
|
||||
return;
|
||||
|
||||
Decree decree;
|
||||
@ -103,8 +105,7 @@ namespace paxos
|
||||
|
||||
quorum_previous_votes.insert(std::pair<std::string, Vote>
|
||||
(sender, vote));
|
||||
int nb_legislators = legislators.size();
|
||||
int quorum_size = quorum_previous_votes.size();
|
||||
unsigned int quorum_size = quorum_previous_votes.size();
|
||||
if (quorum_size > nb_legislators / 2)
|
||||
receive_enough_last_vote();
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user