diff --git a/hbs2-peer/app/BlockDownload.hs b/hbs2-peer/app/BlockDownload.hs index 6732b674..447d80d3 100644 --- a/hbs2-peer/app/BlockDownload.hs +++ b/hbs2-peer/app/BlockDownload.hs @@ -534,6 +534,7 @@ postponedLoop env0 = do pause @'Seconds 10 wip1 <- asks (view blockWip) >>= liftIO . Cache.keys wip2 <- liftIO $ readTVarIO twip + trace $ "download stuck chech" <+> pretty wip1 <+> pretty wip2 when (length wip1 == wip2) do trace "download stuck" diff --git a/hbs2-peer/app/PeerTypes.hs b/hbs2-peer/app/PeerTypes.hs index 6650fc4a..b6a945bc 100644 --- a/hbs2-peer/app/PeerTypes.hs +++ b/hbs2-peer/app/PeerTypes.hs @@ -285,7 +285,7 @@ addDownload h = do notPostponed <- liftIO $ readTVarIO po <&> isNothing . HashMap.lookup h - when (doAdd && notPostponed && notHere) do + if (doAdd && notPostponed && notHere) then do q <- asks (view downloadQ) wip <- asks (view blockWip) @@ -296,6 +296,11 @@ addDownload h = do writeTQueue q h Cache.insert wip h () + else do + -- FIXME: wtf? + po <- asks (view peerPostponed) + liftIO $ atomically $ do + modifyTVar po $ HashMap.insert h () -- | False -> do -- not hasSize -> do