From 19efaca1db008a58a1c1b65395465550ec0b72b6 Mon Sep 17 00:00:00 2001 From: Sam T Date: Tue, 9 Jul 2013 00:09:20 +0400 Subject: ~ Move DHT to single module. --- src/Data/Kademlia/Common.hs | 48 --------------------------------------------- 1 file changed, 48 deletions(-) delete mode 100644 src/Data/Kademlia/Common.hs (limited to 'src/Data/Kademlia') diff --git a/src/Data/Kademlia/Common.hs b/src/Data/Kademlia/Common.hs deleted file mode 100644 index 874120d8..00000000 --- a/src/Data/Kademlia/Common.hs +++ /dev/null @@ -1,48 +0,0 @@ -{-# OPTIONS -fno-warn-orphans #-} -{-# LANGUAGE RecordWildCards #-} -module Data.Kademlia.Common - (NodeID, NodeInfo - ) where - -import Control.Applicative -import Data.ByteString -import Network -import Network.Socket -import Data.Serialize - - -type NodeID = ByteString -type Distance = NodeID - --- WARN is the 'system' random suitable for this? --- | Generate random NodeID used for the entire session. --- Distribution of ID's should be as uniform as possible. --- -genNodeID :: IO NodeID -genNodeID = undefined -- randomIO - -instance Serialize PortNumber where - get = fromIntegral <$> getWord16be - put = putWord16be . fromIntegral - - -data NodeAddr = NodeAddr { - nodeIP :: HostAddress - , nodePort :: PortNumber - } deriving (Show, Eq) - -instance Serialize NodeAddr where - get = NodeAddr <$> getWord32be <*> get - put NodeAddr {..} = do - putWord32be nodeIP - put nodePort - - -data NodeInfo = NodeInfo { - nodeID :: NodeID - , nodeAddr :: NodeAddr - } deriving (Show, Eq) - -instance Serialize NodeInfo where - get = NodeInfo <$> getByteString 20 <*> get - put NodeInfo {..} = put nodeID >> put nodeAddr -- cgit v1.2.3