#ifndef paxos_h
#define paxos_h
-#include "types.h"
-#include "rpc/rpc.h"
-#include "paxos_protocol.h"
-#include "log.h"
+#include "include/types.h"
+#include "include/rpc/rpc.h"
+#include "include/paxos_protocol.h"
+#include "include/log.h"
using prepareres = paxos_protocol::prepareres;
using node_t = paxos_protocol::node_t;
unsigned instance_h = 0; // number of the highest instance we have decided
std::map<unsigned,value_t> values; // vals of each instance
- friend class log;
- class log l = {this, me};
+ class log l = {me};
void commit(unsigned instance, const value_t & v, lock & acceptor_mutex_lock);
void breakpoint1();
void breakpoint2();
+ // Log a committed paxos instance
+ struct log_instance {
+ unsigned number;
+ string value;
+ MEMBERS(number, value)
+ LABEL("done")
+ };
+
+ // Log the highest proposal number that the local paxos acceptor has
+ // ever seen; called from paxos when responding to preparereq with
+ // accept
+ struct log_proposal {
+ prop_t promise;
+ MEMBERS(promise)
+ LABEL("propseen")
+ };
+
+ // Log the highest proposal (proposal number and value) that the local
+ // paxos acceptor accept has ever accepted; called from paxos when
+ // responding to acceptreq with true
+ struct log_accept {
+ prop_t number;
+ string value;
+ MEMBERS(number, value)
+ LABEL("accepted")
+ };
+
public:
proposer_acceptor(paxos_change *delegate, bool _first, const node_t & _me, const value_t & _value);
unsigned instance() { return instance_h; }
const value_t & value(unsigned instance) { return values[instance]; }
- string dump() { return l.dump(); }
- void restore(const string & s) { l.restore(s); l.logread(); }
+ string dump() { return l.read(); }
+ void restore(const string & s) { l.write(s); l.replay(); }
rpcs *get_rpcs() { return &pxs; }
bool run(unsigned instance, const nodes_t & cnodes, const value_t & v);