summaryrefslogtreecommitdiff
path: root/src/Network/DHT/Kademlia.hs
diff options
context:
space:
mode:
authorSam T <pxqr.sta@gmail.com>2013-05-17 05:06:00 +0400
committerSam T <pxqr.sta@gmail.com>2013-05-17 05:06:00 +0400
commit3d53b08b7fe4a7727418670e510d826eae576f14 (patch)
treee7d2cb26077b6ab4ab5e732034bc23d542419a85 /src/Network/DHT/Kademlia.hs
parent448b86fca5cac5abfef66598391614a8a4f83a46 (diff)
~ Reorganize modules.
Diffstat (limited to 'src/Network/DHT/Kademlia.hs')
-rw-r--r--src/Network/DHT/Kademlia.hs21
1 files changed, 9 insertions, 12 deletions
diff --git a/src/Network/DHT/Kademlia.hs b/src/Network/DHT/Kademlia.hs
index d5418beb..bc03ac16 100644
--- a/src/Network/DHT/Kademlia.hs
+++ b/src/Network/DHT/Kademlia.hs
@@ -1,4 +1,3 @@
1-- TODO move to Network.DHT.Kademlia
2{-# LANGUAGE OverloadedStrings #-} 1{-# LANGUAGE OverloadedStrings #-}
3module Network.DHT.Kademlia 2module Network.DHT.Kademlia
4 ( 3 (
@@ -8,7 +7,8 @@ import Data.ByteString
8import Network 7import Network
9import Remote.KRPC 8import Remote.KRPC
10 9
11 10import Data.Kademlia.Routing.Table
11{-
12 12
13-- | Global unique identifier of the node. Size of the identifier 13-- | Global unique identifier of the node. Size of the identifier
14-- should(!) be equal to the size of DHT keys. This limitation arises 14-- should(!) be equal to the size of DHT keys. This limitation arises
@@ -32,11 +32,7 @@ type Token = ByteString
32ping :: Method NodeID NodeID 32ping :: Method NodeID NodeID
33ping = method "ping" ["id"] ["id"] 33ping = method "ping" ["id"] ["id"]
34 34
35type PeerContact = () 35
36data NodeContact = NodeContact {
37 peerContact :: PeerContact
38 , nodeID :: NodeID
39 }
40 36
41-- | Used to lookup peer ID from node ID. 37-- | Used to lookup peer ID from node ID.
42-- 38--
@@ -47,16 +43,16 @@ find_node = method "find_node" ["id", "target"] ["id", "nodes"]
47announce_peer :: Method (NodeID, InfoHash, PortNumber, Token) NodeID 43announce_peer :: Method (NodeID, InfoHash, PortNumber, Token) NodeID
48announce_peer = undefined 44announce_peer = undefined
49 45
46-- WARN is the 'system' random suitable for this?
47-- | Generate random NodeID used for the entire session.
48-- Distribution of ID's should be as uniform as possible.
49--
50genNodeID :: IO NodeID 50genNodeID :: IO NodeID
51genNodeID = undefined 51genNodeID = randomIO
52 52
53{- 53{-
54type InfoHash = Int
55type Token = Int 54type Token = Int
56 55
57ping :: Method NodeId NodeId
58ping = method "ping" ["id"] ["id"]
59
60get_peers :: Method (NodeId :*: InfoHash) (NodeId, Token, NodeAddr :|: NodeAddr) 56get_peers :: Method (NodeId :*: InfoHash) (NodeId, Token, NodeAddr :|: NodeAddr)
61get_peers = method "get_peers" 57get_peers = method "get_peers"
62 ("id", "target") 58 ("id", "target")
@@ -65,4 +61,5 @@ get_peers = method "get_peers"
65 61
66 62
67 63
64-}
68-} \ No newline at end of file 65-} \ No newline at end of file