<commit_before>module Main where

import           Consensus             (runClient, runServer)
import           Http                  (site)

import           Control.Concurrent    (MVar, newEmptyMVar)
import           Control.Concurrent    (forkIO)
import           Control.Monad         (forever)
import           Data.ByteString       (ByteString)
import           Data.ByteString.Char8 as BSC8 (pack)

host = "0.0.0.0"
port = 9160

main :: IO ()
main = do
  httpToConsensus <- newEmptyMVar
  forkIO $ forever (runServer host port)
  forkIO $ forever (runClient httpToConsensus host port)
  site httpToConsensus<commit_msg>in transition towards multi-follower demo<commit_after>module Main where

import           Consensus             (runClient, runServer)
import           Http                  (site)

import           Control.Concurrent    (MVar, newEmptyMVar)
import           Control.Concurrent    (forkIO)
import           Control.Monad         (forever)
import           Data.ByteString       (ByteString)
import           Data.ByteString.Char8 as BSC8 (pack)
import           Data.List             (partition)
import           System.Environment    (getArgs)

host = "0.0.0.0"
port = 9160

main :: IO ()
main = do
  xs <- getArgs
  case xs of
    [] -> doIt [([port], [port])]
    xs -> doIt (ss ((map read xs) :: [Int]))

doIt lfs =
  mapM_ (\([leader], followers) -> doIt' leader followers) lfs
 where
  doIt' leader peers = do
    httpToConsensus <- newEmptyMVar
    forkIO $ forever (runServer host leader)
    forkIO $ forever (runClient httpToConsensus host leader)
    site httpToConsensus

ss :: Eq a => [a] -> [([a], [a])]
ss xs =  map (\x -> partition ((==) x) xs) xs

{-
CMD --> L --> F1
          --> F2
-}
{'fraction_non_alphanumeric': 0.10392609699769054, 'fraction_numerical': 0.012702078521939953, 'mean_word_length': 2.051056338028169, 'pattern_counts': {'":': 0, '<': 6, '<?xml version=': 0, '>': 12, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 2, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6746241', 'n_tokens_mistral': 542, 'n_tokens_neox': 519, 'n_words': 158}