Signed-off-by: Louis Solofrizzo <lsolofrizzo@scaleway.com>
---
libfloat.c | 23 +++++++++++++++++++++--libfloat.h | 25 +++++++++++++++++++++++++log.c | 2 +-
3 files changed, 47 insertions(+), 3 deletions(-)
diff --git a/libfloat.c b/libfloat.c
index 59c3e8b..62525fb 100644
--- a/libfloat.c+++ b/libfloat.c
@@ -21,7 +21,7 @@ libfloat_ctx_t *libfloat_ctx_new(void *(*malloc)(size_t), void *(*calloc)(size_t
ret->conf.log_commit_timeout = 5;
ret->conf.compact_every_n_log = 10000;
ret->conf.avoid_congestion = false;
- ret->conf.sanity_timeout = 6;+ ret->conf.sanity_timeout = 10; ret->conf.optimistic_replication = true;
ret->conf.max_logs_per_ae = 500;
ret->conf.do_revert = false;
@@ -114,4 +114,23 @@ libfloat_entry_id_t libfloat_node_get_next_log(libfloat_node_t *node)
libfloat_entry_id_t libfloat_node_get_replicated_log(libfloat_node_t *node)
{
return node->replicated_log;
-}
\ No newline at end of file
+}++void libfloat_reset_timeout_elapsed(libfloat_ctx_t *ctx)+{+ if (!libfloat_am_i_leader(ctx))+ {+ ctx->timeout_elapsed = 0;+ }+}++void libfloat_update_last_update(libfloat_ctx_t *ctx, libfloat_node_id_t id)+{+ if (libfloat_am_i_leader(ctx))+ {+ libfloat_node_t *node = libfloat_get_node(ctx, id);++ if (node != NULL)+ node->last_update = ctx->time(NULL);+ }+}
diff --git a/libfloat.h b/libfloat.h
index 69f040f..0e724fa 100644
--- a/libfloat.h+++ b/libfloat.h
@@ -540,4 +540,29 @@ libfloat_entry_id_t libfloat_node_get_next_log(libfloat_node_t *node);
*/
libfloat_entry_id_t libfloat_node_get_replicated_log(libfloat_node_t *node);
+/*!+ * \brief Reset timeout elasped on followers, in order not to trigger an election+ *+ * \param[in] ctx Libfloat context+ *+ * \note Follower function only+ * \note This function is intended to be called when network happens outside of+ * libfloat (like snapshotting), and the timer needs to be reseted in order not+ * to trigger an election.+ */+void libfloat_reset_timeout_elapsed(libfloat_ctx_t *ctx);++/*!+ * \brief Update the last hearbeat we received from a node+ *+ * \param[in] ctx Libfloat context+ * \param[in] id Node ID to update+ *+ * \note Leader function only+ * \note This function is intended to be valled when network happens outside of