From ecf5add30d2fdeceeaf2cd38b0232d0f1f2590d9 Mon Sep 17 00:00:00 2001 From: voidlizard Date: Wed, 6 Nov 2024 09:50:28 +0300 Subject: [PATCH] better? --- hbs2-peer/app/RPC2.hs | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/hbs2-peer/app/RPC2.hs b/hbs2-peer/app/RPC2.hs index 4fe06e8f..89c0abe6 100644 --- a/hbs2-peer/app/RPC2.hs +++ b/hbs2-peer/app/RPC2.hs @@ -242,15 +242,13 @@ runBurstMachine BurstMachine{..} = do pause @'Seconds 600 atomically $ writeTVar _buMaxReal buMax - forever do - - e1 <- readTVarIO _buErrors + flip fix 0 $ \next e1 -> do let dt = realToFrac _buTimeout pause @'Seconds dt - atomically do + eNew <- atomically do e2 <- readTVar _buErrors current <- readTVar _buCurrent @@ -270,6 +268,10 @@ runBurstMachine BurstMachine{..} = do modifyTVar _rates ( Map.insertWith max dedt current ) + pure e2 + + next eNew + data S = SInit | SFetchQ