diff options
Diffstat (limited to 'src/Network/BitTorrent/DHT/ContactInfo.hs')
-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 | ||