summaryrefslogtreecommitdiff
path: root/src/Network/BitTorrent/DHT/ContactInfo.hs
diff options
context:
space:
mode:
authorjoe <joe@jerkface.net>2017-07-27 08:23:10 -0400
committerjoe <joe@jerkface.net>2017-07-27 08:23:10 -0400
commit7a4b181bf39c3e33f0d9a78390fc6237cee783f8 (patch)
tree29773b7147c4366d7b1085c2cf6eee33c744e406 /src/Network/BitTorrent/DHT/ContactInfo.hs
parent59a12c22732741754fbd3f58c05aa6324aea273a (diff)
Bug-fix: Enabled storing multiple peers in a swarm.
Diffstat (limited to 'src/Network/BitTorrent/DHT/ContactInfo.hs')
-rw-r--r--src/Network/BitTorrent/DHT/ContactInfo.hs6
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
176swarmInsert :: SwarmData -> SwarmData -> SwarmData 176swarmInsert :: SwarmData -> SwarmData -> SwarmData
177swarmInsert old new = SwarmData 177swarmInsert 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
182isSwarmOccupied SwarmData{..} = not $ PSQ.null peers 184isSwarmOccupied SwarmData{..} = not $ PSQ.null peers
183 185