1 #include "include/log.h"
2 #include "include/paxos.h"
4 // Maintains durable state (i.e. surviving power failures) needed for correct
5 // operation of Paxos as a log.
7 log::log(string _me) : name("paxos-" + _me + ".log") {}
10 auto from = unmarshall(read());
13 DEBUG_LOG << "Replaying paxos log from disk";
14 while (from >> type) {
15 if (handlers.count(type)) {
18 DEBUG_LOG << "unknown log record";
25 return (std::stringstream() << std::ifstream(name).rdbuf()).str();
28 void log::write(string s) {
30 std::ofstream(name, std::ios::trunc) << s;