diff options
author | joe <joe@jerkface.net> | 2017-01-17 18:33:49 -0500 |
---|---|---|
committer | joe <joe@jerkface.net> | 2017-01-17 18:33:49 -0500 |
commit | 9d3b8a2589aef84472746dd57306b9d07920e073 (patch) | |
tree | 02b6cb80c829fc05560b067f6af65e43b3a8b934 /src/Network/BitTorrent/DHT/ContactInfo.hs | |
parent | f694874bbede64d43ed71ca9f4541e565e30fcbb (diff) |
Using -- so disabled code is indicated by grep.
Diffstat (limited to 'src/Network/BitTorrent/DHT/ContactInfo.hs')
-rw-r--r-- | src/Network/BitTorrent/DHT/ContactInfo.hs | 182 |
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 | |||
13 | import Data.Torrent | 13 | import Data.Torrent |
14 | import Network.BitTorrent.Address | 14 | import Network.BitTorrent.Address |
15 | 15 | ||
16 | {- | 16 | -- {- |
17 | import Data.HashMap.Strict as HM | 17 | -- import Data.HashMap.Strict as HM |
18 | 18 | -- | |
19 | import Data.Torrent.InfoHash | 19 | -- import Data.Torrent.InfoHash |
20 | import 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 | -- | |
30 | type 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 | -- | |
34 | takeNewest :: PeerSet a -> [PeerAddr a] | 34 | -- takeNewest :: PeerSet a -> [PeerAddr a] |
35 | takeNewest = undefined | 35 | -- takeNewest = undefined |
36 | 36 | -- | |
37 | dropOld :: Timestamp -> PeerSet a -> PeerSet a | 37 | -- dropOld :: Timestamp -> PeerSet a -> PeerSet a |
38 | dropOld = undefined | 38 | -- dropOld = undefined |
39 | 39 | -- | |
40 | insert :: PeerAddr a -> Timestamp -> PeerSet a -> PeerSet a | 40 | -- insert :: PeerAddr a -> Timestamp -> PeerSet a -> PeerSet a |
41 | insert = undefined | 41 | -- insert = undefined |
42 | 42 | -- | |
43 | type Mask = Int | 43 | -- type Mask = Int |
44 | type Size = Int | 44 | -- type Size = Int |
45 | type 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 | -- | |
53 | data 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 | -- | |
58 | insertTree :: InfoHash -> a -> Tree a -> Tree a | 58 | -- insertTree :: InfoHash -> a -> Tree a -> Tree a |
59 | insertTree = undefined | 59 | -- insertTree = undefined |
60 | 60 | -- | |
61 | type Prio = Int | 61 | -- type Prio = Int |
62 | 62 | -- | |
63 | --shrink :: ContactInfo ip -> Int | 63 | -- --shrink :: ContactInfo ip -> Int |
64 | shrink Nil = Nil | 64 | -- shrink Nil = Nil |
65 | shrink (Tip _ _) = undefined | 65 | -- shrink (Tip _ _) = undefined |
66 | shrink (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 | -- | |
74 | data IntMap k p a | 74 | -- data IntMap k p a |
75 | type ContactInfo = Map InfoHash Timestamp (Set (PeerAddr IP) Timestamp) | 75 | -- type ContactInfo = Map InfoHash Timestamp (Set (PeerAddr IP) Timestamp) |
76 | 76 | -- | |
77 | data 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 | -- | |
86 | size :: ContactInfo ip -> Int | 86 | -- size :: ContactInfo ip -> Int |
87 | size = undefined | 87 | -- size = undefined |
88 | 88 | -- | |
89 | prefixSize :: ContactInfo ip -> Int | 89 | -- prefixSize :: ContactInfo ip -> Int |
90 | prefixSize = undefined | 90 | -- prefixSize = undefined |
91 | 91 | -- | |
92 | lookup :: InfoHash -> ContactInfo ip -> [PeerAddr ip] | 92 | -- lookup :: InfoHash -> ContactInfo ip -> [PeerAddr ip] |
93 | lookup = undefined | 93 | -- lookup = undefined |
94 | 94 | -- | |
95 | insert :: InfoHash -> PeerAddr ip -> ContactInfo ip -> ContactInfo ip | 95 | -- insert :: InfoHash -> PeerAddr ip -> ContactInfo ip -> ContactInfo ip |
96 | insert = undefined | 96 | -- insert = undefined |
97 | 97 | -- | |
98 | -- | Limit in size. | 98 | -- -- | Limit in size. |
99 | prune :: NodeId -> Int -> ContactInfo ip -> ContactInfo ip | 99 | -- prune :: NodeId -> Int -> ContactInfo ip -> ContactInfo ip |
100 | prune pref targetSize Nil = Nil | 100 | -- prune pref targetSize Nil = Nil |
101 | prune pref targetSize (Tip _ _) = undefined | 101 | -- prune pref targetSize (Tip _ _) = undefined |
102 | 102 | -- | |
103 | -- | Remove expired entries. | 103 | -- -- | Remove expired entries. |
104 | splitGT :: Timestamp -> ContactInfo ip -> ContactInfo ip | 104 | -- splitGT :: Timestamp -> ContactInfo ip -> ContactInfo ip |
105 | splitGT = 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. |