wip, fix download

This commit is contained in:
voidlizard 2024-11-04 05:20:20 +03:00
parent 5b03bdd05b
commit 5239e39fbe
3 changed files with 7 additions and 7 deletions

View File

@ -81,7 +81,7 @@ defBlockWaitMax = 60 :: Timeout 'Seconds
-- how much time wait for block from peer? -- how much time wait for block from peer?
defChunkWaitMax :: Timeout 'Seconds defChunkWaitMax :: Timeout 'Seconds
defChunkWaitMax = 5 :: Timeout 'Seconds defChunkWaitMax = 10 :: Timeout 'Seconds
defSweepTimeout :: Timeout 'Seconds defSweepTimeout :: Timeout 'Seconds
defSweepTimeout = 60 -- FIXME: only for debug! defSweepTimeout = 60 -- FIXME: only for debug!

View File

@ -315,13 +315,13 @@ blockDownloadLoop env0 = do
let blkInfoLock = 5 :: Timeout 'Seconds let blkInfoLock = 5 :: Timeout 'Seconds
let blkWaitLock = 60 :: Timeout 'Seconds let blkWaitLock = 60 :: Timeout 'Seconds
let workloadFactor = 1.10 let workloadFactor = 2.5
e <- ask e <- ask
sto <- getStorage sto <- getStorage
let downT = 16 let downT = 16
let sizeT = 16 let sizeT = 4
inQ <- withDownload env0 $ asks (view blockInQ) inQ <- withDownload env0 $ asks (view blockInQ)
checkQ <- withDownload env0 $ asks (view blockCheckQ) checkQ <- withDownload env0 $ asks (view blockCheckQ)

View File

@ -95,7 +95,7 @@ blockChunksProto adapter (BlockChunks c p) = do
case p of case p of
BlockGetChunks h size n1 num | auth -> do BlockGetChunks h size n1 num | auth -> deferred @proto do
bsz' <- blkSize adapter h bsz' <- blkSize adapter h
@ -104,11 +104,11 @@ blockChunksProto adapter (BlockChunks c p) = do
let offsets' = calcChunks bsz (fromIntegral size) :: [(Offset, Size)] let offsets' = calcChunks bsz (fromIntegral size) :: [(Offset, Size)]
let offsets = take (fromIntegral num) $ drop (fromIntegral n1) $ zip offsets' [0..] let offsets = take (fromIntegral num) $ drop (fromIntegral n1) $ zip offsets' [0..]
for_ offsets $ \((o,sz),i) -> deferred @proto do for_ offsets $ \((o,sz),i) -> do
chunk <- blkChunk adapter h o sz chunk <- blkChunk adapter h o sz
maybe (pure ()) (response_ . BlockChunk @e i) chunk maybe (pure ()) (response_ . BlockChunk @e i) chunk
BlockGetAllChunks h size | auth -> do BlockGetAllChunks h size | auth -> deferred @proto do
bsz' <- blkSize adapter h bsz' <- blkSize adapter h
@ -117,7 +117,7 @@ blockChunksProto adapter (BlockChunks c p) = do
let offsets' = calcChunks bsz (fromIntegral size) :: [(Offset, Size)] let offsets' = calcChunks bsz (fromIntegral size) :: [(Offset, Size)]
let offsets = zip offsets' [0..] let offsets = zip offsets' [0..]
for_ offsets $ \((o,sz),i) -> deferred @proto do for_ offsets $ \((o,sz),i) -> do
chunk <- blkChunk adapter h o sz chunk <- blkChunk adapter h o sz
maybe (pure ()) (response_ . BlockChunk @e i) chunk maybe (pure ()) (response_ . BlockChunk @e i) chunk