From e5950b9ca9b08eec4a6a15f6583756997047719c Mon Sep 17 00:00:00 2001 From: voidlizard Date: Thu, 14 Nov 2024 20:51:17 +0300 Subject: [PATCH] ... --- hbs2-peer/app/BlockDownloadNew.hs | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/hbs2-peer/app/BlockDownloadNew.hs b/hbs2-peer/app/BlockDownloadNew.hs index c7432081..bde5f8cc 100644 --- a/hbs2-peer/app/BlockDownloadNew.hs +++ b/hbs2-peer/app/BlockDownloadNew.hs @@ -169,6 +169,7 @@ data BurstMachine = , _buStepUp :: Double , _buStepDown :: Double , _buCurrent :: TVar Double + , _buMaxReal :: TVar Double , _buErrors :: TVar Int } @@ -193,6 +194,7 @@ newBurstMachine :: MonadUnliftIO m newBurstMachine t0 buMax buStart up' down' = do BurstMachine t0 bu0 buMax up down <$> newTVarIO bu0 + <*> newTVarIO bu0 <*> newTVarIO 0 where @@ -208,7 +210,8 @@ instance MonadUnliftIO m => IsBurstMachine BurstMachine m where burstMachineReset BurstMachine{..} = do atomically do - writeTVar _buCurrent _buStart + bmr <- readTVar _buMaxReal + writeTVar _buCurrent (min bmr _buStart) writeTVar _buErrors 0 runBurstMachine BurstMachine{..} = do @@ -223,8 +226,6 @@ instance MonadUnliftIO m => IsBurstMachine BurstMachine m where _rates <- newTVarIO (mempty :: Map Double Double) - _buMaxReal <- newTVarIO buMax - pause @'Seconds (realToFrac _buTimeout) flip runContT pure do