lead :: (RaftLog l e v) => Raft l e v -> IO ()
lead vRaft = do
    raft <- atomically $ do
        modifyTVar (raftContext vRaft) $ \oldRaft -> do
            let name = raftName oldRaft
                cfg = raftStateConfiguration $ raftState oldRaft
                members = mkMembers cfg $ lastCommittedTime $ raftLog oldRaft
            setRaftLeader (Just name)
                $ setRaftLastCandidate Nothing 
                $ setRaftMembers members oldRaft
        readTVar (raftContext vRaft)
    let name = raftName raft
        term = raftCurrentTerm raft
    clients <- atomically $ newMailbox
    actions <- atomically $ newMailbox
    infoM _log $ printf "Server %v leading in term %v with members %s" name (show term) (show $ raftMembers raft)
    raceAll_ $ [doPulse vRaft actions,
                doVote vRaft,
                doRespond vRaft,
                doServe vRaft actions,
                doPerform vRaft actions clients]
lead :: (RaftLog l e v) => Raft l e v -> IO ()
lead vRaft = do
    raft <- atomically $ do
        modifyTVar (raftContext vRaft) $ \oldRaft -> do
            let name = raftName oldRaft
                cfg = raftStateConfiguration $ raftState oldRaft
                members = mkMembers cfg $ lastCommittedTime $ raftLog oldRaft
            setRaftLeader (Just name)
                $ setRaftLastCandidate Nothing 
                $ setRaftMembers members oldRaft
        readTVar (raftContext vRaft)
    let name = raftName raft
        term = raftCurrentTerm raft
    clients <- atomically $ newMailbox
    actions <- atomically $ newMailbox
    infoM _log $ printf "Server %v leading in term %v with members %s" name (show term) (show $ raftMembers raft)
    raceAll_ $ [doPulse vRaft actions,
                doVote vRaft,
                doRespond vRaft,
                doServe vRaft actions,
                doPerform vRaft actions clients]
lead vRaft = do
    raft <- atomically $ do
        modifyTVar (raftContext vRaft) $ \oldRaft -> do
            let name = raftName oldRaft
                cfg = raftStateConfiguration $ raftState oldRaft
                members = mkMembers cfg $ lastCommittedTime $ raftLog oldRaft
            setRaftLeader (Just name)
                $ setRaftLastCandidate Nothing 
                $ setRaftMembers members oldRaft
        readTVar (raftContext vRaft)
    let name = raftName raft
        term = raftCurrentTerm raft
    clients <- atomically $ newMailbox
    actions <- atomically $ newMailbox
    infoM _log $ printf "Server %v leading in term %v with members %s" name (show term) (show $ raftMembers raft)
    raceAll_ $ [doPulse vRaft actions,
                doVote vRaft,
                doRespond vRaft,
                doServe vRaft actions,
                doPerform vRaft actions clients]