deltamesh-federated-privacy.../delta_mesh/delta_crdt.h

21 lines
464 B
C

// Lightweight CRDT-like delta structure and merge utility
#ifndef DELTA_CRDT_H
#define DELTA_CRDT_H
typedef struct DeltaCRDT {
unsigned long version;
double value_delta;
} DeltaCRDT;
// Merge two deltas by choosing the one with the higher version.
static inline void crdt_merge(const DeltaCRDT* a, const DeltaCRDT* b, DeltaCRDT* out) {
if (!a || !b || !out) return;
if (a->version >= b->version) {
*out = *a;
} else {
*out = *b;
}
}
#endif