summaryrefslogtreecommitdiff
path: root/src/Network
diff options
context:
space:
mode:
Diffstat (limited to 'src/Network')
-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