Skip to content

Commit

Permalink
consensus: use bracketWithRegistry for ChainSync servers
Browse files Browse the repository at this point in the history
We intend for this change to make it more difficult to repeat the mistake
underlying Issue #2870.
  • Loading branch information
nfrisby committed Jan 22, 2021
1 parent 475e531 commit caf1c7c
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 13 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -359,17 +359,16 @@ mkApps kernel Tracers {..} Codecs {..} Handlers {..} =
-> m ((), Maybe bCS)
aChainSyncServer them channel = do
labelThisThread "LocalChainSyncServer"
withRegistry $ \registry ->
bracket
(chainSyncBlockServerFollower (getChainDB kernel) registry)
ChainDB.followerClose
(\flr -> runPeer
bracketWithRegistry
(chainSyncBlockServerFollower (getChainDB kernel))
ChainDB.followerClose
$ \_registry flr ->
runPeer
(contramap (TraceLabelPeer them) tChainSyncTracer)
cChainSyncCodec
channel
$ chainSyncServerPeer
$ hChainSyncServer flr
)

aTxSubmissionServer
:: localPeer
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -487,20 +487,19 @@ mkApps kernel Tracers {..} Codecs {..} genChainSyncTimeout Handlers {..} =
-> m ((), Maybe bCS)
aChainSyncServer version them channel = do
labelThisThread "ChainSyncServer"
withRegistry $ \registry -> do
chainSyncTimeout <- genChainSyncTimeout
bracket
(chainSyncHeaderServerFollower (getChainDB kernel) registry)
ChainDB.followerClose
(\flr -> runPeerWithLimits
chainSyncTimeout <- genChainSyncTimeout
bracketWithRegistry
(chainSyncHeaderServerFollower (getChainDB kernel))
ChainDB.followerClose
$ \_registry flr ->
runPeerWithLimits
(contramap (TraceLabelPeer them) tChainSyncSerialisedTracer)
cChainSyncCodecSerialised
(byteLimitsChainSync (const 0)) -- TODO: Real Bytelimits, see #1727
(timeLimitsChainSync chainSyncTimeout)
channel
$ chainSyncServerPeer
$ hChainSyncServer flr version
)

aBlockFetchClient
:: NodeToNodeVersion
Expand Down

0 comments on commit caf1c7c

Please sign in to comment.