diff options
Diffstat (limited to 'dht/src/Data/Tox/DHT/Multi.hs')
-rw-r--r-- | dht/src/Data/Tox/DHT/Multi.hs | 27 |
1 files changed, 1 insertions, 26 deletions
diff --git a/dht/src/Data/Tox/DHT/Multi.hs b/dht/src/Data/Tox/DHT/Multi.hs index 8d614262..acd645a3 100644 --- a/dht/src/Data/Tox/DHT/Multi.hs +++ b/dht/src/Data/Tox/DHT/Multi.hs | |||
@@ -11,7 +11,7 @@ import Crypto.PubKey.Curve25519 (PublicKey) | |||
11 | import qualified Network.Tox.NodeId as UDP | 11 | import qualified Network.Tox.NodeId as UDP |
12 | ;import Network.Tox.NodeId (NodeId) | 12 | ;import Network.Tox.NodeId (NodeId) |
13 | import qualified Network.Tox.TCP.NodeId as TCP | 13 | import qualified Network.Tox.TCP.NodeId as TCP |
14 | import Data.Tox.Onion (OnionDestination,RouteId,AnnouncedRendezvous) | 14 | import Data.Tox.Onion (OnionDestination,RouteId) |
15 | import Data.Tox.Relay hiding (NodeInfo) | 15 | import Data.Tox.Relay hiding (NodeInfo) |
16 | import Network.Address (either4or6) | 16 | import Network.Address (either4or6) |
17 | import Network.Tox.TCP as TCP (ViaRelay(..), tcpConnectionRequest_) | 17 | import Network.Tox.TCP as TCP (ViaRelay(..), tcpConnectionRequest_) |
@@ -95,28 +95,10 @@ type NodeInfo = DSum T Identity | |||
95 | type SessionAddress = DSum S Identity | 95 | type SessionAddress = DSum S Identity |
96 | type OnionAddress = DSum O Identity | 96 | type OnionAddress = DSum O Identity |
97 | 97 | ||
98 | data R addr where | ||
99 | RendezvousUDP :: R AnnouncedRendezvous | ||
100 | RendezvousTCP :: R AnnouncedRendezvous | ||
101 | |||
102 | instance GEq R where | ||
103 | geq RendezvousUDP RendezvousUDP = Just Refl | ||
104 | geq RendezvousTCP RendezvousTCP = Just Refl | ||
105 | geq _ _ = Nothing | ||
106 | instance GCompare R where | ||
107 | gcompare RendezvousUDP RendezvousUDP = GEQ | ||
108 | gcompare RendezvousUDP RendezvousTCP = GLT | ||
109 | gcompare RendezvousTCP RendezvousTCP = GEQ | ||
110 | gcompare RendezvousTCP RendezvousUDP = GGT | ||
111 | instance GShow R where | ||
112 | gshowsPrec _ RendezvousUDP = showString "UDP" | ||
113 | gshowsPrec _ RendezvousTCP = showString "TCP" | ||
114 | |||
115 | #if MIN_VERSION_dependent_sum(0,6,0) | 98 | #if MIN_VERSION_dependent_sum(0,6,0) |
116 | deriveArgDict ''T | 99 | deriveArgDict ''T |
117 | deriveArgDict ''S | 100 | deriveArgDict ''S |
118 | deriveArgDict ''O | 101 | deriveArgDict ''O |
119 | deriveArgDict ''R | ||
120 | #else | 102 | #else |
121 | instance ShowTag T Identity where | 103 | instance ShowTag T Identity where |
122 | showTaggedPrec UDP = showsPrec | 104 | showTaggedPrec UDP = showsPrec |
@@ -133,15 +115,8 @@ instance EqTag S Identity where | |||
133 | instance OrdTag S Identity where | 115 | instance OrdTag S Identity where |
134 | compareTagged SessionUDP SessionUDP = compare | 116 | compareTagged SessionUDP SessionUDP = compare |
135 | compareTagged SessionTCP SessionTCP = compare | 117 | compareTagged SessionTCP SessionTCP = compare |
136 | instance ShowTag R Identity where | ||
137 | showTaggedPrec RendezvousUDP = showsPrec | ||
138 | showTaggedPrec RendezvousTCP = showsPrec | ||
139 | #endif | 118 | #endif |
140 | 119 | ||
141 | untagRendezvous :: DSum R Identity -> AnnouncedRendezvous | ||
142 | untagRendezvous (RendezvousUDP :=> Identity o) = o | ||
143 | untagRendezvous (RendezvousTCP :=> Identity o) = o | ||
144 | |||
145 | 120 | ||
146 | nodeInfo :: NodeId -> DSum S Identity -> Either String (DSum T Identity) | 121 | nodeInfo :: NodeId -> DSum S Identity -> Either String (DSum T Identity) |
147 | nodeInfo nid (SessionUDP :=> Identity saddr) = fmap (UDP ==>) $ UDP.nodeInfo nid saddr | 122 | nodeInfo nid (SessionUDP :=> Identity saddr) = fmap (UDP ==>) $ UDP.nodeInfo nid saddr |