#ifndef paxos_protocol_h
#define paxos_protocol_h
+#include "types.h"
#include "rpc/rpc.h"
struct prop_t {
unsigned n;
- std::string m;
+ string m;
+
+ MEMBERS(n, m)
+ LEXICOGRAPHIC_COMPARISON(prop_t)
};
+MARSHALLABLE(prop_t)
+
class paxos_protocol {
public:
enum status : status_t { OK, ERR };
heartbeat,
};
- struct preparearg {
- unsigned instance;
- prop_t n;
- };
-
struct prepareres {
bool oldinstance;
bool accept;
prop_t n_a;
- std::string v_a;
- };
-
- struct acceptarg {
- unsigned instance;
- prop_t n;
- std::string v;
- };
+ string v_a;
- struct decidearg {
- unsigned instance;
- std::string v;
+ MEMBERS(oldinstance, accept, n_a, v_a)
};
};
-inline unmarshall & operator>>(unmarshall &u, prop_t &a) {
- return u >> a.n >> a.m;
-}
-
-inline marshall & operator<<(marshall &m, prop_t a) {
- return m << a.n << a.m;
-}
-
-inline unmarshall & operator>>(unmarshall &u, paxos_protocol::preparearg &a) {
- return u >> a.instance >> a.n;
-}
-
-inline marshall & operator<<(marshall &m, paxos_protocol::preparearg a) {
- return m << a.instance << a.n;
-}
-
-inline unmarshall & operator>>(unmarshall &u, paxos_protocol::prepareres &r) {
- return u >> r.oldinstance >> r.accept >> r.n_a >> r.v_a;
-}
-
-inline marshall & operator<<(marshall &m, paxos_protocol::prepareres r) {
- return m << r.oldinstance << r.accept << r.n_a << r.v_a;
-}
-
-inline unmarshall & operator>>(unmarshall &u, paxos_protocol::acceptarg &a) {
- return u >> a.instance >> a.n >> a.v;
-}
-
-inline marshall & operator<<(marshall &m, paxos_protocol::acceptarg a) {
- return m << a.instance << a.n << a.v;
-}
-
-inline unmarshall & operator>>(unmarshall &u, paxos_protocol::decidearg &a) {
- return u >> a.instance >> a.v;
-}
-
-inline marshall & operator<<(marshall &m, paxos_protocol::decidearg a) {
- return m << a.instance << a.v;
-}
+MARSHALLABLE(paxos_protocol::prepareres)
#endif