Skip to content

Commit

Permalink
diffusion: refactored order of calls
Browse files Browse the repository at this point in the history
In a following patch we will need the `readInboundState` to be available
for creation of `PeerSelectionActions`.
  • Loading branch information
coot committed May 6, 2024
1 parent 7fb0f5a commit c3312f2
Showing 1 changed file with 19 additions and 19 deletions.
38 changes: 19 additions & 19 deletions ouroboros-network/src/Ouroboros/Network/Diffusion/P2P.hs
Original file line number Diff line number Diff line change
Expand Up @@ -1098,25 +1098,25 @@ runM Interfaces
outboundInfoChannel <- newInformationChannel
withConnectionManagerInitiatorAndResponderMode
inboundInfoChannel
outboundInfoChannel $ \connectionManager -> do
debugStateVar <- newTVarIO $ emptyPeerSelectionState fuzzRng
diInstallSigUSR1Handler connectionManager debugStateVar daPeerMetrics
withPeerStateActions' connectionManager $ \peerStateActions ->
withPeerSelectionActions'
PeerSelectionActionsDiffusionMode {
psNewInboundConnections = readMessage outboundInfoChannel,
psPeerStateActions = peerStateActions } $
\(ledgerPeersThread, localRootPeersProvider) peerSelectionActions->
Async.withAsync
(peerSelectionGovernor' dtDebugPeerSelectionInitiatorResponderTracer debugStateVar peerSelectionActions) $ \governorThread ->
-- begin, unique to InitiatorAndResponder mode:
withSockets' $ \sockets addresses -> do
traceWith tracer (RunServer addresses)
withServer sockets connectionManager inboundInfoChannel $ \inboundGovernorThread _ ->
-- end, unique to ...
Async.withAsync peerChurnGovernor' $ \churnGovernorThread ->
-- wait for any thread to fail:
snd <$> Async.waitAny [ledgerPeersThread, localRootPeersProvider, governorThread, churnGovernorThread, inboundGovernorThread]
outboundInfoChannel $ \connectionManager ->
withSockets' $ \sockets addresses -> do
withServer sockets connectionManager inboundInfoChannel $ \inboundGovernorThread _readInboundState -> do
debugStateVar <- newTVarIO $ emptyPeerSelectionState fuzzRng
diInstallSigUSR1Handler connectionManager debugStateVar daPeerMetrics
withPeerStateActions' connectionManager $ \peerStateActions ->
withPeerSelectionActions'
PeerSelectionActionsDiffusionMode {
psNewInboundConnections = readMessage outboundInfoChannel,
psPeerStateActions = peerStateActions } $
\(ledgerPeersThread, localRootPeersProvider) peerSelectionActions ->
Async.withAsync
(peerSelectionGovernor' dtDebugPeerSelectionInitiatorResponderTracer debugStateVar peerSelectionActions) $ \governorThread -> do
-- begin, unique to InitiatorAndResponder mode:
traceWith tracer (RunServer addresses)
-- end, unique to ...
Async.withAsync peerChurnGovernor' $ \churnGovernorThread ->
-- wait for any thread to fail:
snd <$> Async.waitAny [ledgerPeersThread, localRootPeersProvider, governorThread, churnGovernorThread, inboundGovernorThread]

-- | Main entry point for data diffusion service. It allows to:
--
Expand Down

0 comments on commit c3312f2

Please sign in to comment.