From 3d53b08b7fe4a7727418670e510d826eae576f14 Mon Sep 17 00:00:00 2001 From: Sam T Date: Fri, 17 May 2013 05:06:00 +0400 Subject: ~ Reorganize modules. --- src/Data/Kademlia/Routing/Table.hs | 50 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 50 insertions(+) create mode 100644 src/Data/Kademlia/Routing/Table.hs (limited to 'src/Data/Kademlia/Routing/Table.hs') diff --git a/src/Data/Kademlia/Routing/Table.hs b/src/Data/Kademlia/Routing/Table.hs new file mode 100644 index 00000000..056692f3 --- /dev/null +++ b/src/Data/Kademlia/Routing/Table.hs @@ -0,0 +1,50 @@ +-- | +-- Copyright : (c) Sam T. 2013 +-- License : MIT +-- Maintainer : pxqr.sta@gmail.com +-- Stability : experimental +-- Portability : portable +-- +-- Routing table used to lookup . Internally it uses not balanced tree +-- +-- TODO write module synopsis +module Data.Kademlia.Routing.Table + ( -- ContactInfo +-- , Table + ) where + +import Control.Applicative +import Data.ByteString +import Data.List as L +import Data.Maybe + +import Network.BitTorrent.Peer + +{- +type NodeID = ByteString +type InfoHash = ByteString + +data ContactInfo = ContactInfo { + peerAddr :: PeerAddr + , nodeID :: NodeID + } deriving (Show, Eq) + + +type Distance = NodeID + +-- | +data Table = Table { + routeTree :: Tree + , maxBucketSize :: Int + } + +insert :: NodeID -> Table -> Table +insert x t = undefined + +closest :: InfoHash -> Table -> [NodeID] +closest = undefined + + +-- TODO table serialization: usually we need to save table between +-- target program executions for bootstrapping +-} \ No newline at end of file -- cgit v1.2.3