summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorjoe <joe@jerkface.net>2017-09-05 23:55:38 -0400
committerjoe <joe@jerkface.net>2017-09-05 23:55:38 -0400
commit2423be0ebf0bcdc4568b251cd8f9a9830bf9b04f (patch)
tree0e4771dcca363349448128f59710977de11c421b
parent186a0c7e24efc8e70274076ebf106e7e23085561 (diff)
Top-level signatures.
-rw-r--r--examples/dhtd.hs6
1 files changed, 6 insertions, 0 deletions
diff --git a/examples/dhtd.hs b/examples/dhtd.hs
index 3f6dcaf4..232abd6e 100644
--- a/examples/dhtd.hs
+++ b/examples/dhtd.hs
@@ -68,6 +68,7 @@ import Data.Time.Clock.POSIX
68showReport :: [(String,String)] -> String 68showReport :: [(String,String)] -> String
69showReport kvs = showColumns $ map (\(x,y)->[x,y]) kvs 69showReport kvs = showColumns $ map (\(x,y)->[x,y]) kvs
70 70
71showColumns :: [[[Char]]] -> [Char]
71showColumns rows = do 72showColumns rows = do
72 let cols = transpose rows 73 let cols = transpose rows
73 ws = map (maximum . map (succ . length)) cols 74 ws = map (maximum . map (succ . length)) cols
@@ -247,6 +248,8 @@ forkSearch method nid DHTQuery{qsearch,qshowTok,qshowR} dhtSearches dhtBuckets
247 modifyTVar' dhtSearches $ Map.insert (method,nid) new 248 modifyTVar' dhtSearches $ Map.insert (method,nid) new
248 writeTVar kvar $ Just $ searchLoop qsearch nid storeResult st 249 writeTVar kvar $ Just $ searchLoop qsearch nid storeResult st
249 250
251reportSearchResults :: (Show t, Ord t1, Ord t, Hashable t) =>
252 String -> Handle -> DHTSearch t1 t -> IO ()
250reportSearchResults meth h DHTSearch{searchShowTok,searchState,searchResults} = do 253reportSearchResults meth h DHTSearch{searchShowTok,searchState,searchResults} = do
251 (ns,rs) <- atomically $ do 254 (ns,rs) <- atomically $ do
252 mm <- readTVar $ searchInformant searchState 255 mm <- readTVar $ searchInformant searchState
@@ -269,6 +272,7 @@ data Session = Session
269 , signalQuit :: MVar () 272 , signalQuit :: MVar ()
270 } 273 }
271 274
275clientSession :: Session -> t1 -> t -> Handle -> IO ()
272clientSession s@Session{..} sock cnum h = do 276clientSession s@Session{..} sock cnum h = do
273 line <- map toLower . dropWhile isSpace <$> hGetLine h 277 line <- map toLower . dropWhile isSpace <$> hGetLine h
274 let (c,args) = second (dropWhile isSpace) $ break isSpace line 278 let (c,args) = second (dropWhile isSpace) $ break isSpace line
@@ -464,8 +468,10 @@ readExternals vars = do
464 -- TODO: Filter to only global addresses? 468 -- TODO: Filter to only global addresses?
465 return $ filter (not . unspecified) as 469 return $ filter (not . unspecified) as
466 470
471defaultPort :: String
467defaultPort = "6881" 472defaultPort = "6881"
468 473
474main :: IO ()
469main = do 475main = do
470 args <- getArgs 476 args <- getArgs
471 p <- case take 2 (dropWhile (/="-p") args) of 477 p <- case take 2 (dropWhile (/="-p") args) of