summaryrefslogtreecommitdiff
path: root/src/Network/BitTorrent/DHT
diff options
context:
space:
mode:
authorjoe <joe@jerkface.net>2017-01-17 18:33:49 -0500
committerjoe <joe@jerkface.net>2017-01-17 18:33:49 -0500
commit9d3b8a2589aef84472746dd57306b9d07920e073 (patch)
tree02b6cb80c829fc05560b067f6af65e43b3a8b934 /src/Network/BitTorrent/DHT
parentf694874bbede64d43ed71ca9f4541e565e30fcbb (diff)
Using -- so disabled code is indicated by grep.
Diffstat (limited to 'src/Network/BitTorrent/DHT')
-rw-r--r--src/Network/BitTorrent/DHT/ContactInfo.hs182
1 files changed, 91 insertions, 91 deletions
diff --git a/src/Network/BitTorrent/DHT/ContactInfo.hs b/src/Network/BitTorrent/DHT/ContactInfo.hs
index 4293506d..d7c92e35 100644
--- a/src/Network/BitTorrent/DHT/ContactInfo.hs
+++ b/src/Network/BitTorrent/DHT/ContactInfo.hs
@@ -13,97 +13,97 @@ import Data.Serialize
13import Data.Torrent 13import Data.Torrent
14import Network.BitTorrent.Address 14import Network.BitTorrent.Address
15 15
16{- 16-- {-
17import Data.HashMap.Strict as HM 17-- import Data.HashMap.Strict as HM
18 18--
19import Data.Torrent.InfoHash 19-- import Data.Torrent.InfoHash
20import Network.BitTorrent.Address 20-- import Network.BitTorrent.Address
21 21--
22-- increase prefix when table is too large 22-- -- increase prefix when table is too large
23-- decrease prefix when table is too small 23-- -- decrease prefix when table is too small
24-- filter outdated peers 24-- -- filter outdated peers
25 25--
26{----------------------------------------------------------------------- 26-- {-----------------------------------------------------------------------
27-- PeerSet 27-- -- PeerSet
28-----------------------------------------------------------------------} 28-- -----------------------------------------------------------------------}
29 29--
30type PeerSet a = [(PeerAddr a, NodeInfo a, Timestamp)] 30-- type PeerSet a = [(PeerAddr a, NodeInfo a, Timestamp)]
31 31--
32-- compare PSQueue vs Ordered list 32-- -- compare PSQueue vs Ordered list
33 33--
34takeNewest :: PeerSet a -> [PeerAddr a] 34-- takeNewest :: PeerSet a -> [PeerAddr a]
35takeNewest = undefined 35-- takeNewest = undefined
36 36--
37dropOld :: Timestamp -> PeerSet a -> PeerSet a 37-- dropOld :: Timestamp -> PeerSet a -> PeerSet a
38dropOld = undefined 38-- dropOld = undefined
39 39--
40insert :: PeerAddr a -> Timestamp -> PeerSet a -> PeerSet a 40-- insert :: PeerAddr a -> Timestamp -> PeerSet a -> PeerSet a
41insert = undefined 41-- insert = undefined
42 42--
43type Mask = Int 43-- type Mask = Int
44type Size = Int 44-- type Size = Int
45type Timestamp = Int 45-- type Timestamp = Int
46 46--
47{----------------------------------------------------------------------- 47-- {-----------------------------------------------------------------------
48-- InfoHashMap 48-- -- InfoHashMap
49-----------------------------------------------------------------------} 49-- -----------------------------------------------------------------------}
50 50--
51-- compare handwritten prefix tree versus IntMap 51-- -- compare handwritten prefix tree versus IntMap
52 52--
53data Tree a 53-- data Tree a
54 = Nil 54-- = Nil
55 | Tip !InfoHash !(PeerSet a) 55-- | Tip !InfoHash !(PeerSet a)
56 | Bin !InfoHash !Mask !Size !Timestamp (Tree a) (Tree a) 56-- | Bin !InfoHash !Mask !Size !Timestamp (Tree a) (Tree a)
57 57--
58insertTree :: InfoHash -> a -> Tree a -> Tree a 58-- insertTree :: InfoHash -> a -> Tree a -> Tree a
59insertTree = undefined 59-- insertTree = undefined
60 60--
61type Prio = Int 61-- type Prio = Int
62 62--
63--shrink :: ContactInfo ip -> Int 63-- --shrink :: ContactInfo ip -> Int
64shrink Nil = Nil 64-- shrink Nil = Nil
65shrink (Tip _ _) = undefined 65-- shrink (Tip _ _) = undefined
66shrink (Bin _ _) = undefined 66-- shrink (Bin _ _) = undefined
67 67--
68{----------------------------------------------------------------------- 68-- {-----------------------------------------------------------------------
69-- InfoHashMap 69-- -- InfoHashMap
70-----------------------------------------------------------------------} 70-- -----------------------------------------------------------------------}
71 71--
72-- compare new design versus HashMap 72-- -- compare new design versus HashMap
73 73--
74data IntMap k p a 74-- data IntMap k p a
75type ContactInfo = Map InfoHash Timestamp (Set (PeerAddr IP) Timestamp) 75-- type ContactInfo = Map InfoHash Timestamp (Set (PeerAddr IP) Timestamp)
76 76--
77data ContactInfo ip = PeerStore 77-- data ContactInfo ip = PeerStore
78 { maxSize :: Int 78-- { maxSize :: Int
79 , prefixSize :: Int 79-- , prefixSize :: Int
80 , thisNodeId :: NodeId 80-- , thisNodeId :: NodeId
81 81--
82 , count :: Int -- ^ Cached size of the 'peerSet' 82-- , count :: Int -- ^ Cached size of the 'peerSet'
83 , peerSet :: HashMap InfoHash [PeerAddr ip] 83-- , peerSet :: HashMap InfoHash [PeerAddr ip]
84 } 84-- }
85 85--
86size :: ContactInfo ip -> Int 86-- size :: ContactInfo ip -> Int
87size = undefined 87-- size = undefined
88 88--
89prefixSize :: ContactInfo ip -> Int 89-- prefixSize :: ContactInfo ip -> Int
90prefixSize = undefined 90-- prefixSize = undefined
91 91--
92lookup :: InfoHash -> ContactInfo ip -> [PeerAddr ip] 92-- lookup :: InfoHash -> ContactInfo ip -> [PeerAddr ip]
93lookup = undefined 93-- lookup = undefined
94 94--
95insert :: InfoHash -> PeerAddr ip -> ContactInfo ip -> ContactInfo ip 95-- insert :: InfoHash -> PeerAddr ip -> ContactInfo ip -> ContactInfo ip
96insert = undefined 96-- insert = undefined
97 97--
98-- | Limit in size. 98-- -- | Limit in size.
99prune :: NodeId -> Int -> ContactInfo ip -> ContactInfo ip 99-- prune :: NodeId -> Int -> ContactInfo ip -> ContactInfo ip
100prune pref targetSize Nil = Nil 100-- prune pref targetSize Nil = Nil
101prune pref targetSize (Tip _ _) = undefined 101-- prune pref targetSize (Tip _ _) = undefined
102 102--
103-- | Remove expired entries. 103-- -- | Remove expired entries.
104splitGT :: Timestamp -> ContactInfo ip -> ContactInfo ip 104-- splitGT :: Timestamp -> ContactInfo ip -> ContactInfo ip
105splitGT = undefined 105-- splitGT = undefined
106-} 106-- -}
107 107
108-- | Storage used to keep track a set of known peers in client, 108-- | Storage used to keep track a set of known peers in client,
109-- tracker or DHT sessions. 109-- tracker or DHT sessions.