From c5c307d29ac262f9bddb4e126820d0008ff9cb12 Mon Sep 17 00:00:00 2001 From: German Date: Tue, 23 Apr 2019 20:27:24 +0100 Subject: [PATCH] Functions sendVote and sendReqForVote --- raft/basic/AUTHORS.md | 6 ++++++ raft/basic/main.c | 17 +++++++++++++++++ 2 files changed, 23 insertions(+) diff --git a/raft/basic/AUTHORS.md b/raft/basic/AUTHORS.md index f97ce7c..46da8c7 100644 --- a/raft/basic/AUTHORS.md +++ b/raft/basic/AUTHORS.md @@ -7,3 +7,9 @@ JAVIER DE MENA PACHECO TERESA VIDAL ASIER LOPEZ + +GERMÁN BRAVO LÓPEZ + +JUAN FERNÁNDEZ BLASCO + +JOSE JUAN CABRERA HIGUERAS diff --git a/raft/basic/main.c b/raft/basic/main.c index 29d281d..8fe106c 100644 --- a/raft/basic/main.c +++ b/raft/basic/main.c @@ -139,11 +139,28 @@ static void replyAppendEntries(fsm_t *this) } static void sendVote (fsm_t* this) { + fsm_raft_t* raft = (fsm_raft_t*) this; + raft->term = term_recv(); //actualizar mi term, hay que implementar term_recv() + //mensaje + message_t* msg; + msg->src_id; //hay que establecer el id en el mensaje con el mio, habrá que guardar el id del nodo en la struct fsm_raft_t + msg->type = MSG_VOTE; + //udp_server_send_Vote(&msg); falta por implementar (en funcion de como se reciben los msg) + printf("sendVote\n"); } static void sendReqForVote (fsm_t* this) { fsm_raft_t* raft = (fsm_raft_t*) this; + //candidatura + raft->term++; + raft->votes=1; + //mensaje + message_t* msg; + msg->src_id; //hay que establecer el id del mensaje con el que tengo + msg->type = MSG_REQVOTE; + //udp_server_send_ReqForVote(&msg); falta por implementar (en funcion de como se reciben los msg) + struct timeval now; gettimeofday (&now, NULL); timeval_add(&raft->next, timeout_candidate , &now);//mirar tiempos