diff options
author | joe <joe@jerkface.net> | 2017-07-27 08:23:10 -0400 |
---|---|---|
committer | joe <joe@jerkface.net> | 2017-07-27 08:23:10 -0400 |
commit | 7a4b181bf39c3e33f0d9a78390fc6237cee783f8 (patch) | |
tree | 29773b7147c4366d7b1085c2cf6eee33c744e406 /src/Network/BitTorrent/DHT | |
parent | 59a12c22732741754fbd3f58c05aa6324aea273a (diff) |
Bug-fix: Enabled storing multiple peers in a swarm.
Diffstat (limited to 'src/Network/BitTorrent/DHT')
-rw-r--r-- | src/Network/BitTorrent/DHT/ContactInfo.hs | 6 |
1 files changed, 4 insertions, 2 deletions
diff --git a/src/Network/BitTorrent/DHT/ContactInfo.hs b/src/Network/BitTorrent/DHT/ContactInfo.hs index b7d7f2a2..9c336f93 100644 --- a/src/Network/BitTorrent/DHT/ContactInfo.hs +++ b/src/Network/BitTorrent/DHT/ContactInfo.hs | |||
@@ -174,10 +174,12 @@ swarmSingleton a = SwarmData | |||
174 | , name = Nothing } | 174 | , name = Nothing } |
175 | 175 | ||
176 | swarmInsert :: SwarmData -> SwarmData -> SwarmData | 176 | swarmInsert :: SwarmData -> SwarmData -> SwarmData |
177 | swarmInsert old new = SwarmData | 177 | swarmInsert new old = SwarmData |
178 | { peers = L.foldl' (\q (a :-> t) -> PSQ.insertWith (\p _ -> p) a t q) (peers old) (PSQ.toList $ peers new) | 178 | { peers = L.foldl' (\q (a :-> t) -> PSQ.insertWith newerTimeStamp a t q) (peers old) (PSQ.toList $ peers new) |
179 | , name = name new <|> name old -- TODO: decodeUtf8' check | 179 | , name = name new <|> name old -- TODO: decodeUtf8' check |
180 | } | 180 | } |
181 | where | ||
182 | newerTimeStamp newtime oldtime = if newtime > oldtime then newtime else oldtime | ||
181 | 183 | ||
182 | isSwarmOccupied SwarmData{..} = not $ PSQ.null peers | 184 | isSwarmOccupied SwarmData{..} = not $ PSQ.null peers |
183 | 185 | ||