diff options
-rw-r--r-- | src/Network/BitTorrent/Tracker/List.hs | 9 |
1 files changed, 6 insertions, 3 deletions
diff --git a/src/Network/BitTorrent/Tracker/List.hs b/src/Network/BitTorrent/Tracker/List.hs index 5ab43c86..1e22f7ec 100644 --- a/src/Network/BitTorrent/Tracker/List.hs +++ b/src/Network/BitTorrent/Tracker/List.hs | |||
@@ -135,11 +135,14 @@ traverseAll action = traverse (action $?) | |||
135 | 135 | ||
136 | -- | Like 'traverse' but put working trackers to the head of tiers. | 136 | -- | Like 'traverse' but put working trackers to the head of tiers. |
137 | -- This can help to avoid exceessive requests to not available | 137 | -- This can help to avoid exceessive requests to not available |
138 | -- trackers at each reannounce. | 138 | -- trackers at each reannounce. If no one action succeed then original |
139 | -- list is returned. | ||
139 | traverseTiers :: (a -> IO a) -> TrackerList a -> IO (TrackerList a) | 140 | traverseTiers :: (a -> IO a) -> TrackerList a -> IO (TrackerList a) |
140 | traverseTiers action (Announce a) = Announce <$> action a | 141 | traverseTiers action ts = catchRPC (goList ts) (return ts) |
141 | traverseTiers action (TierList tiers) = TierList <$> goTiers (goTier []) tiers | ||
142 | where | 142 | where |
143 | goList (Announce a) = Announce <$> action a | ||
144 | goList (TierList tiers) = TierList <$> goTiers (goTier []) tiers | ||
145 | |||
143 | goTiers _ [] = throwRPC "traverseTiers: no tiers" | 146 | goTiers _ [] = throwRPC "traverseTiers: no tiers" |
144 | goTiers f (x : xs) = catchRPC shortcut failback | 147 | goTiers f (x : xs) = catchRPC shortcut failback |
145 | where | 148 | where |