paxos/src/legislator/legislator.hh

32 lines
727 B
C++
Raw Normal View History

2020-05-05 12:11:54 +00:00
#pragma once
2020-05-05 12:47:12 +00:00
#include "config/config.hh"
2020-05-05 17:29:14 +00:00
#include "ledger.hh"
#include <unordered_map>
2020-05-05 12:11:54 +00:00
namespace paxos
{
class Legislator
{
public:
2020-05-05 12:47:12 +00:00
Legislator(const LegislatorConfig& config);
LegislatorConfig config_;
2020-05-05 12:11:54 +00:00
2020-05-05 17:29:14 +00:00
void initiate_ballot();
void send_next_ballot(int ballot);
void receive_next_ballot(int ballot, std::string sender);
void receive_enough_last_vote
(std::unordered_map<std::string, int> quorum_last_votes);
void receive_begin_ballot(int ballot, int decree);
Ledger ledger;
2020-05-05 12:47:12 +00:00
};
using shared_legislator = std::shared_ptr<Legislator>;
2020-05-05 17:29:14 +00:00
extern shared_legislator self;
extern std::vector<shared_legislator> legislators;
2020-05-05 12:11:54 +00:00
}