debug: sumultaneous-downloads-coeff

This commit is contained in:
Dmitry Zuikov 2023-10-20 06:59:41 +03:00
parent 0f0eb2a494
commit 44ada95e3f
1 changed files with 11 additions and 3 deletions

View File

@ -137,19 +137,27 @@ instance ( Hashable (Peer e)
downs <- liftIO $ readTVarIO (view brainsPostponeDown b) downs <- liftIO $ readTVarIO (view brainsPostponeDown b)
r <- forM peers $ \p -> do r <- forM peers $ \p -> do
let v = HashMap.lookup (p,h) downs & fromMaybe 0 & (<4) let v = HashMap.lookup (p,h) downs & fromMaybe 0 & (<simK)
pure [v] pure [v]
let postpone = not (List.null r || or (mconcat r) ) let postpone = not (List.null r || or (mconcat r) )
pure postpone pure postpone
where
simK = 10
-- FIXME: investigate-simK-affects-anything
-- проверить
shouldDownloadBlock b p h = do shouldDownloadBlock b p h = do
noPeers <- liftIO $ readTVarIO (view brainsPeers b) <&> List.null noPeers <- liftIO $ readTVarIO (view brainsPeers b) <&> List.null
downs <- liftIO $ readTVarIO (view brainsPostponeDown b) downs <- liftIO $ readTVarIO (view brainsPostponeDown b)
let doo = HashMap.lookup (p,h) downs & fromMaybe 0 & (<4) let doo = HashMap.lookup (p,h) downs & fromMaybe 0 & (<simK)
-- trace $ "shouldDownloadBlock" <+> pretty noPeers <+> pretty doo -- trace $ "shouldDownloadBlock" <+> pretty noPeers <+> pretty doo
pure $ noPeers || (HashMap.lookup (p,h) downs & fromMaybe 0 & (<4)) pure $ noPeers || (HashMap.lookup (p,h) downs & fromMaybe 0 & (<simK))
where
-- TODO: simK-to-settings
-- в настройки, если на что-либо влияет
simK = 10
advisePeersForBlock b h = do advisePeersForBlock b h = do
r <- liftIO $ findPeers b h r <- liftIO $ findPeers b h