#>cpp
#pragma once

#include <cstring>
#include <vector>

#include "raft/log_entry.hpp"
#include "rpc/messages.hpp"
cpp<#

(lcp:namespace raft)

(lcp:define-rpc request-vote
  (:request
    ((candidate-id :uint16_t)
     (term :uint64_t)
     (last-log-index :uint64_t)
     (last-log-term :uint64_t)))
  (:response
    ((vote-granted :bool)
     (term :uint64_t))))

(lcp:define-rpc append-entries
  (:request
    ((leader-id :uint16_t)
     (leader-commit :uint64_t)
     (term :uint64_t)
     (prev-log-index :uint64_t)
     (prev-log-term :uint64_t)
     (entries "std::vector<raft::LogEntry>")))
  (:response
    ((success :bool)
     (term :uint64_t))))

(lcp:define-rpc heartbeat
  (:request
    ((leader-id :uint16_t)
     (term :uint64_t)))
  (:response
    ((success :bool)
     (term :uint64_t))))

(lcp:pop-namespace) ;; raft
