diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/Network/BitTorrent/MainlineDHT.hs | 14 | ||||
-rw-r--r-- | src/Network/Kademlia/Search.hs | 4 | ||||
-rw-r--r-- | src/Network/Tox/DHT/Handlers.hs | 6 | ||||
-rw-r--r-- | src/Network/Tox/Onion/Handlers.hs | 2 |
4 files changed, 13 insertions, 13 deletions
diff --git a/src/Network/BitTorrent/MainlineDHT.hs b/src/Network/BitTorrent/MainlineDHT.hs index f4a5ade1..eb06564a 100644 --- a/src/Network/BitTorrent/MainlineDHT.hs +++ b/src/Network/BitTorrent/MainlineDHT.hs | |||
@@ -1013,19 +1013,19 @@ ping client addr = | |||
1013 | <$> mainlineSend (Method "ping") (\Pong -> True) (const Ping) client () addr | 1013 | <$> mainlineSend (Method "ping") (\Pong -> True) (const Ping) client () addr |
1014 | 1014 | ||
1015 | -- searchQuery :: ni -> IO (Maybe [ni], [r], tok)) | 1015 | -- searchQuery :: ni -> IO (Maybe [ni], [r], tok)) |
1016 | getNodes :: MainlineClient -> NodeId -> NodeInfo -> IO (Maybe ([NodeInfo],[NodeInfo],())) | 1016 | getNodes :: MainlineClient -> NodeId -> NodeInfo -> IO (Maybe ([NodeInfo],[NodeInfo],Maybe ())) |
1017 | getNodes = mainlineSend (Method "find_node") unwrapNodes $ flip FindNode (Just Want_Both) | 1017 | getNodes = mainlineSend (Method "find_node") unwrapNodes $ flip FindNode (Just Want_Both) |
1018 | 1018 | ||
1019 | unwrapNodes :: NodeFound -> ([NodeInfo], [NodeInfo], ()) | 1019 | unwrapNodes :: NodeFound -> ([NodeInfo], [NodeInfo], Maybe ()) |
1020 | unwrapNodes (NodeFound ns4 ns6) = (ns4++ns6, ns4++ns6,()) | 1020 | unwrapNodes (NodeFound ns4 ns6) = (ns4++ns6, ns4++ns6, Just ()) |
1021 | 1021 | ||
1022 | getPeers :: MainlineClient -> NodeId -> NodeInfo -> IO (Maybe ([NodeInfo],[PeerAddr],Token)) | 1022 | getPeers :: MainlineClient -> NodeId -> NodeInfo -> IO (Maybe ([NodeInfo],[PeerAddr],Maybe Token)) |
1023 | getPeers = mainlineSend (Method "get_peers") unwrapPeers $ flip GetPeers (Just Want_Both) . coerce | 1023 | getPeers = mainlineSend (Method "get_peers") unwrapPeers $ flip GetPeers (Just Want_Both) . coerce |
1024 | 1024 | ||
1025 | unwrapPeers :: GotPeers -> ([NodeInfo], [PeerAddr], Token) | 1025 | unwrapPeers :: GotPeers -> ([NodeInfo], [PeerAddr], Maybe Token) |
1026 | unwrapPeers (GotPeers ps (NodeFound ns4 ns6) tok) = (ns4++ns6, ps, tok) | 1026 | unwrapPeers (GotPeers ps (NodeFound ns4 ns6) tok) = (ns4++ns6, ps, Just tok) |
1027 | 1027 | ||
1028 | mainlineSearch :: (NodeId -> NodeInfo -> IO (Maybe ([NodeInfo], [r], tok))) | 1028 | mainlineSearch :: (NodeId -> NodeInfo -> IO (Maybe ([NodeInfo], [r], Maybe tok))) |
1029 | -> Search NodeId (IP, PortNumber) tok NodeInfo r | 1029 | -> Search NodeId (IP, PortNumber) tok NodeInfo r |
1030 | mainlineSearch qry = Search | 1030 | mainlineSearch qry = Search |
1031 | { searchSpace = mainlineSpace | 1031 | { searchSpace = mainlineSpace |
diff --git a/src/Network/Kademlia/Search.hs b/src/Network/Kademlia/Search.hs index 9d51e815..58c8fad8 100644 --- a/src/Network/Kademlia/Search.hs +++ b/src/Network/Kademlia/Search.hs | |||
@@ -38,7 +38,7 @@ import GHC.Conc (labelThread) | |||
38 | data Search nid addr tok ni r = Search | 38 | data Search nid addr tok ni r = Search |
39 | { searchSpace :: KademliaSpace nid ni | 39 | { searchSpace :: KademliaSpace nid ni |
40 | , searchNodeAddress :: ni -> addr | 40 | , searchNodeAddress :: ni -> addr |
41 | , searchQuery :: nid -> ni -> IO (Maybe ([ni], [r], tok)) | 41 | , searchQuery :: nid -> ni -> IO (Maybe ([ni], [r], Maybe tok)) |
42 | } | 42 | } |
43 | 43 | ||
44 | data SearchState nid addr tok ni r = SearchState | 44 | data SearchState nid addr tok ni r = SearchState |
@@ -61,7 +61,7 @@ data SearchState nid addr tok ni r = SearchState | |||
61 | -- | Nodes scheduled to be queried. | 61 | -- | Nodes scheduled to be queried. |
62 | , searchQueued :: TVar (MinMaxPSQ ni nid) | 62 | , searchQueued :: TVar (MinMaxPSQ ni nid) |
63 | -- | The nearest K nodes that issued a reply. | 63 | -- | The nearest K nodes that issued a reply. |
64 | , searchInformant :: TVar (MinMaxPSQ' ni nid tok) | 64 | , searchInformant :: TVar (MinMaxPSQ' ni nid (Maybe tok)) |
65 | -- | This tracks already-queried addresses so we avoid bothering them | 65 | -- | This tracks already-queried addresses so we avoid bothering them |
66 | -- again. XXX: We could probably keep only the pending queries in this | 66 | -- again. XXX: We could probably keep only the pending queries in this |
67 | -- set. It also can be a bounded 'MinMaxPSQ', although searchAlpha | 67 | -- set. It also can be a bounded 'MinMaxPSQ', although searchAlpha |
diff --git a/src/Network/Tox/DHT/Handlers.hs b/src/Network/Tox/DHT/Handlers.hs index 4576fc85..89f3d442 100644 --- a/src/Network/Tox/DHT/Handlers.hs +++ b/src/Network/Tox/DHT/Handlers.hs | |||
@@ -306,10 +306,10 @@ unsendNodes :: Message -> Maybe (Asymm (Nonce8,SendNodes)) | |||
306 | unsendNodes (DHTSendNodes asymm) = Just asymm | 306 | unsendNodes (DHTSendNodes asymm) = Just asymm |
307 | unsendNodes _ = Nothing | 307 | unsendNodes _ = Nothing |
308 | 308 | ||
309 | unwrapNodes :: SendNodes -> ( [NodeInfo], [NodeInfo], () ) | 309 | unwrapNodes :: SendNodes -> ( [NodeInfo], [NodeInfo], Maybe () ) |
310 | unwrapNodes (SendNodes ns) = (ns,ns,()) | 310 | unwrapNodes (SendNodes ns) = (ns,ns,Just ()) |
311 | 311 | ||
312 | getNodes :: Client -> NodeId -> NodeInfo -> IO (Maybe ([NodeInfo],[NodeInfo],())) | 312 | getNodes :: Client -> NodeId -> NodeInfo -> IO (Maybe ([NodeInfo],[NodeInfo],Maybe ())) |
313 | getNodes client nid addr = do | 313 | getNodes client nid addr = do |
314 | -- hPutStrLn stderr $ show addr ++ " <-- getnodes " ++ show nid | 314 | -- hPutStrLn stderr $ show addr ++ " <-- getnodes " ++ show nid |
315 | reply <- QR.sendQuery client (serializer GetNodesType DHTGetNodes unsendNodes) (GetNodes nid) addr | 315 | reply <- QR.sendQuery client (serializer GetNodesType DHTGetNodes unsendNodes) (GetNodes nid) addr |
diff --git a/src/Network/Tox/Onion/Handlers.hs b/src/Network/Tox/Onion/Handlers.hs index b06fc2af..e792aa50 100644 --- a/src/Network/Tox/Onion/Handlers.hs +++ b/src/Network/Tox/Onion/Handlers.hs | |||
@@ -171,7 +171,7 @@ handlers net _ _ keydb _ = Just $ NoReply Right $ dataToRouteH keydb net | |||
171 | toxidSearch :: (TransactionId -> OnionDestination r -> STM (OnionDestination r, Int)) | 171 | toxidSearch :: (TransactionId -> OnionDestination r -> STM (OnionDestination r, Int)) |
172 | -> TransportCrypto | 172 | -> TransportCrypto |
173 | -> Client r | 173 | -> Client r |
174 | -> Search NodeId (IP, PortNumber) (Maybe Nonce32) NodeInfo Rendezvous | 174 | -> Search NodeId (IP, PortNumber) Nonce32 NodeInfo Rendezvous |
175 | toxidSearch getTimeout crypto client = Search | 175 | toxidSearch getTimeout crypto client = Search |
176 | { searchSpace = toxSpace | 176 | { searchSpace = toxSpace |
177 | , searchNodeAddress = nodeIP &&& nodePort | 177 | , searchNodeAddress = nodeIP &&& nodePort |