Calling receive_next_ballot after message treatment

This commit is contained in:
Julien CLEMENT 2020-05-05 21:20:27 +02:00
parent 6795dd7127
commit 8f66b98ce3
6 changed files with 70 additions and 4 deletions

@ -0,0 +1,22 @@
{
"legislators" : [
{
"ip" : "127.0.0.1",
"port" : 8000,
"name" : "legislator1",
"self" : true
},
{
"ip" : "127.0.0.1",
"port" : 8001,
"name" : "legislator2",
"self" : false
},
{
"ip" : "127.0.0.1",
"port" : 8002,
"name" : "legislator3",
"self" : false
}
]
}

@ -0,0 +1,22 @@
{
"legislators" : [
{
"ip" : "127.0.0.1",
"port" : 8000,
"name" : "legislator1",
"self" : false
},
{
"ip" : "127.0.0.1",
"port" : 8001,
"name" : "legislator2",
"self" : true
},
{
"ip" : "127.0.0.1",
"port" : 8002,
"name" : "legislator3",
"self" : false
}
]
}

@ -0,0 +1,22 @@
{
"legislators" : [
{
"ip" : "127.0.0.1",
"port" : 8000,
"name" : "legislator1",
"self" : false
},
{
"ip" : "127.0.0.1",
"port" : 8001,
"name" : "legislator2",
"self" : false
},
{
"ip" : "127.0.0.1",
"port" : 8002,
"name" : "legislator3",
"self" : true
}
]
}

@ -1 +0,0 @@
4

@ -1 +0,0 @@
3

@ -28,6 +28,7 @@ namespace paxos
Message message; Message message;
message.set_method("NextBallot"); message.set_method("NextBallot");
message.add_header("ballot", ballot_string); message.add_header("ballot", ballot_string);
message.add_header("sender", self->config_.name);
for (auto legislator : legislators) for (auto legislator : legislators)
SendEW::send_message(message, legislator.second); SendEW::send_message(message, legislator.second);
@ -35,8 +36,9 @@ namespace paxos
void Legislator::receive_next_ballot(Message message) void Legislator::receive_next_ballot(Message message)
{ {
message = message; std::string ballot_str = *message.get_header("ballot");
log("received NextBallot", green); int ballot = std::stoi(ballot_str);
receive_next_ballot(ballot, *message.get_header("sender"));
} }
void Legislator::receive_next_ballot(int ballot, std::string sender) void Legislator::receive_next_ballot(int ballot, std::string sender)