Message parsing and serialization, connection to other legislators
This commit is contained in:
1 parent
fd4de7091c
commit
6b80cc68ce
12 files changed
+337
-11
No files matched your search
@@ -1,6 +1,10 @@
|
||||
#include <string>
|
||||
|
||||
#include "legislator.hh"
|
||||
#include "misc/logger.hh"
|
||||
#include <string>
|
||||
#include "message/message.hh"
|
||||
#include "events/register.hh"
|
||||
#include "events/send.hh"
|
||||
|
||||
namespace paxos
|
||||
{
|
||||
@@ -20,8 +24,13 @@ namespace paxos
|
||||
|
||||
void Legislator::send_next_ballot(int ballot)
|
||||
{
|
||||
ballot = ballot;
|
||||
return;
|
||||
std::string ballot_string = std::to_string(ballot);
|
||||
Message message;
|
||||
message.set_method("NextBallot");
|
||||
message.add_header("ballot", ballot_string);
|
||||
|
||||
for (auto legislator : legislators)
|
||||
SendEW::send_message(message, legislator.second);
|
||||
}
|
||||
|
||||
void Legislator::receive_next_ballot(int ballot, std::string sender)
|
||||
|
||||
@@ -27,5 +27,5 @@ namespace paxos
|
||||
using shared_legislator = std::shared_ptr<Legislator>;
|
||||
|
||||
extern shared_legislator self;
|
||||
extern std::vector<shared_legislator> legislators;
|
||||
extern std::unordered_map<std::string, shared_legislator> legislators;
|
||||
}
|
||||