Skip to content
This repository has been archived by the owner on Aug 18, 2020. It is now read-only.

Commit

Permalink
[CBR-454] Correct window size when streaming blocks
Browse files Browse the repository at this point in the history
When a node syncs with mainnet it maintains a window which controls
how many blocks the peer it syncs with is permitted to have outstanding.
The client incorrectly increased the window which, when the server
manages to send faster than the client was able to write to disk would
lead to a very large memory consumtion until all blocks where written.
  • Loading branch information
karknu committed Sep 28, 2018
1 parent 8251c93 commit 8ba5644
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions lib/src/Pos/Diffusion/Full/Block.hs
Original file line number Diff line number Diff line change
Expand Up @@ -397,11 +397,11 @@ streamBlocks logTrace smM logic streamWindow enqueue nodeId tipHeader checkpoint
-> Word32
-> IO ()
retrieveBlocks bvd blockChan conv window = do
window' <- if window < halfStreamWindow
window' <- if window <= halfStreamWindow
then do
let w' = streamWindow
let w' = window + halfStreamWindow
traceWith logTrace (Debug, sformat ("Updating Window: "%int%" to "%int) window w')
send conv $ MsgUpdate $ MsgStreamUpdate $ w'
send conv $ MsgUpdate $ MsgStreamUpdate halfStreamWindow
return (w' - 1)
else return $ window - 1
block <- retrieveBlock bvd conv
Expand Down

0 comments on commit 8ba5644

Please sign in to comment.