(* Remember to re-run
     python2 script/extract_record_notation.py raft/RaftState.v.rec raft_data > raft/RaftState.v
   after editing this file!
   Running `make raft/RaftState.v` should take care of this for you. *)
Section RaftState.
  Variable term : Type.
  Variable name : Type.
  Variable entry : Type.
  Variable logIndex : Type.
  Variable serverType : Type.
  Variable stateMachineData : Type.
  Variable clientId : Type.
  Variable output : Type.

  Record raft_data :=
    mkRaft_data {
        (* persistent *)
        currentTerm : term;
        votedFor : option name;
        leaderId : option name;
        log : list entry;
        (* volatile *)
        commitIndex : logIndex;
        lastApplied : logIndex;
        stateMachine : stateMachineData;
        (* leader state *)
        nextIndex : list (name * logIndex);
        matchIndex : list (name * logIndex);
        shouldSend : bool;
        (* candidate state *)
        votesReceived : list name;
        (* whoami *)
        type : serverType;
        (* client request state *)
        clientCache : list (clientId * (nat * output));
        (* ghost variables *)
        electoralVictories : list (term * list name * list entry)
      }.
End RaftState.
