Calling receive_next_ballot after message treatment

This commit is contained in:
juju committed 2020-05-05 21:20:27 +02:00
1 parent 6795dd7127
commit 8f66b98ce3
6 files changed
+70 -4

No files matched your search

@@ -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
View File
@@ -1 +0,0 @@
4
-1
View File
@@ -1 +0,0 @@
3
+4 -2
View File
@@ -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)
Reference in new issue
Block a user
Blocking a user prevents them from interacting with repositories, such as opening or commenting on pull requests or issues. Learn more about blocking a user.