1/* @ajax/mesh-fleet-persist: what a fleet member keeps on disk, written before any vote,
2 * acknowledgement or commit leaves it (fleet.rs Persist): its term, its vote in that term, the
3 * last document it accepted from a leader and the last it knows committed. */
4#ifndef MESH_FLEET_PERSIST_H
5#define MESH_FLEET_PERSIST_H
67#include "mesh/fleet_doc.h"
89#include <stdbool.h>
10#include <stdint.h>
1112typedef struct {
13 uint64_t term;
14 bool has_voted;
15 uint32_t voted;
16 mfd_doc accepted, committed;
17} mfp_persist;
1819mfp_persist mfp_clone(const mfp_persist *p);
20bool mfp_eq(const mfp_persist *a, const mfp_persist *b);
21void mfp_free(mfp_persist *p);
22/* The state file's text for a cluster of n. */
23char *mfp_encode(const mfp_persist *p, uint32_t n);
24/* Refuses a file written for another cluster size, and one without both documents. */
25bool mfp_decode(const char *text, uint32_t n, mfp_persist *out, char **err);
2627#endif