X-Git-Url: http://xvm.mit.edu/gitweb/invirt/third/libt4.git/blobdiff_plain/2546a41ad36fdc9ef6471cb35a1d56930ae1b527..5a5c578e2e358a121cdb9234a6cb11c4ecfbf323:/paxos_protocol.h diff --git a/paxos_protocol.h b/paxos_protocol.h index f2bdb3f..c24f155 100644 --- a/paxos_protocol.h +++ b/paxos_protocol.h @@ -1,11 +1,12 @@ #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; }; class paxos_protocol { @@ -18,45 +19,18 @@ class paxos_protocol { 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; - }; - - struct decidearg { - unsigned instance; - std::string v; + string 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, prop_t &a) { return u >> a.n >> a.m; } +inline marshall & operator<<(marshall &m, prop_t a) { return m << a.n << a.m; } +inline bool operator>(const prop_t &a, const prop_t &b) { return tie(a.n, a.m) > tie(b.n, b.m); } +inline bool operator>=(const prop_t &a, const prop_t &b) { return tie(a.n, a.m) >= tie(b.n, b.m); } inline unmarshall & operator>>(unmarshall &u, paxos_protocol::prepareres &r) { return u >> r.oldinstance >> r.accept >> r.n_a >> r.v_a; @@ -66,20 +40,4 @@ 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; -} - #endif