1/* @ajax/mesh-jobs-merge: a member's answer to a new leader's pull (jobs.rs `Answer`) and the merge
2 * of a majority's answers (`merge`), which holds every committed entry because any two majorities
3 * meet. Committed tables are applied first, the latest commit point first; then the entries not
4 * committed yet, the latest leadership's first. The table is a union where an item's first result
5 * wins, so the order decides between two results of one item: a committed result is never
6 * overwritten by an uncommitted one, and between entries the later leadership's wins (review
7 * finding 5). */
8#ifndef MESH_JOBS_MERGE_H
9#define MESH_JOBS_MERGE_H
1011#include "mesh/jobs/log.h"
12#include "mesh/jobs/op.h"
13#include "mesh/jobs/table.h"
14#include "mesh/omap.h"
1516#include <stdbool.h>
17#include <stddef.h>
18#include <stdint.h>
1920typedef struct {
21 uint32_t seq; /* the next part expected; a part out of sequence spoils the answer */
22 bool spoilt;
23 uint64_t commit_lid, commit_n;
24 mj_table committed;
25 momap *entries; /* (leadership, number) -> mj_ops: its entries not committed yet */
26} mj_answer;
2728void mj_answer_init(mj_answer *a);
29void mj_answer_free(mj_answer *a);
30/* The ops of entry (lid, n), created empty if absent. */
31mj_ops *mj_answer_entry(mj_answer *a, uint64_t lid, uint64_t n);
32/* A member's own answer, without frames (the new leader's). */
33mj_answer mj_answer_of(const mj_replica *r);
3435/* The merge of answers[0..n) given in member-id order. */
36mj_table mj_merge(mj_answer *const *answers, size_t n);
3738#endif