This commit is contained in:
Dmitry Zuikov 2023-01-24 07:39:45 +03:00
parent defa1540e5
commit c56400a6b0
1 changed files with 10 additions and 7 deletions

View File

@ -151,8 +151,8 @@ runTestPeer p zu = do
stor <- simpleStorageInit opts stor <- simpleStorageInit opts
cww <- newChunkWriterIO stor (Just chDir) cww <- newChunkWriterIO stor (Just chDir)
sw <- liftIO $ replicateM 8 $ async $ simpleStorageWorker stor sw <- liftIO $ replicateM 4 $ async $ simpleStorageWorker stor
cw <- liftIO $ replicateM 16 $ async $ runChunkWriter cww cw <- liftIO $ replicateM 32 $ async $ runChunkWriter cww
zu stor cww zu stor cww
@ -225,7 +225,7 @@ blockDownloadLoop = do
here <- liftIO $ hasBlock stor h <&> isJust here <- liftIO $ hasBlock stor h <&> isJust
unless here $ do if not here then do
subscribe @e (BlockSizeEventKey h) $ \(BlockSizeEvent (p,hx,s)) -> do subscribe @e (BlockSizeEventKey h) $ \(BlockSizeEvent (p,hx,s)) -> do
initDownload True blq p hx s initDownload True blq p hx s
@ -236,6 +236,9 @@ blockDownloadLoop = do
debug $ "requesting block" <+> pretty h <+> "from" <+> pretty p debug $ "requesting block" <+> pretty h <+> "from" <+> pretty p
request p (GetBlockSize @e h) request p (GetBlockSize @e h)
else do
processBlock blq h
next next
where where
@ -256,17 +259,17 @@ blockDownloadLoop = do
update @e new key id update @e new key id
subscribe @e (BlockChunksEventKey h) $ \(BlockReady _) -> do subscribe @e (BlockChunksEventKey h) $ \(BlockReady _) -> do
processBlock q p h processBlock q h
request p (BlockChunks coo (BlockGetAllChunks @e h chusz)) -- FIXME: nicer construction request p (BlockChunks coo (BlockGetAllChunks @e h chusz)) -- FIXME: nicer construction
| anyway -> processBlock q p h | anyway -> processBlock q h
| otherwise -> do | otherwise -> do
debug $ "already got " <+> pretty h <+> " so relax" debug $ "already got " <+> pretty h <+> " so relax"
pure () pure ()
processBlock q _ h = do processBlock q h = do
env <- ask env <- ask
pip <- asks (view envDeferred) pip <- asks (view envDeferred)
@ -294,7 +297,7 @@ blockDownloadLoop = do
if here then do if here then do
debug $ "block" <+> pretty blk <+> "is already here" debug $ "block" <+> pretty blk <+> "is already here"
pure () -- we don't need to recurse, cause walkMerkle will recurse pure () -- we don't need to recurse, cause walkMerkle is recursing for us
else do else do
-- if block is missed, then -- if block is missed, then