From 0bd62e50cc5eb0a35af2a1d0f1aedc87338ce017 Mon Sep 17 00:00:00 2001 From: voidlizard Date: Tue, 5 Nov 2024 14:11:30 +0300 Subject: [PATCH] wip --- hbs2-peer/app/RPC2.hs | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/hbs2-peer/app/RPC2.hs b/hbs2-peer/app/RPC2.hs index e9737c2c..32c9b367 100644 --- a/hbs2-peer/app/RPC2.hs +++ b/hbs2-peer/app/RPC2.hs @@ -294,16 +294,21 @@ downloadFromPeer t bu cache env h peer = liftIO $ withPeerM env do callCC $ \exit2 -> do for_ bursts $ \(i,chunkN) -> do + + -- s0 <- readTVarIO _sBlockChunks2 <&> IntMap.size + + -- count <- newTVarIO 0 + atomically $ flushTQueue chuQ + let req = BlockChunks @e coo (BlockGetChunks h chunkSize (fromIntegral i) (fromIntegral chunkN)) lift $ request peer req r <- liftIO $ race (pause t) do atomically do - -- readTQueue chuQ - pieces <- readTVar _sBlockChunks2 - let done = and [ IntMap.member j pieces | j <- [i .. i + chunkN-1] ] - unless done retry + pieces <- readTVar _sBlockChunks2 + let done = and [ IntMap.member j pieces | j <- [i .. i + chunkN-1] ] + unless done retry atomically $ flushTQueue chuQ