Skip to content

Commit 83f96d8

Browse files
committed
connect back
1 parent bd996fd commit 83f96d8

File tree

2 files changed

+10
-5
lines changed

2 files changed

+10
-5
lines changed

ouroboros-consensus-diffusion/app/conformance-test-runner/Main.hs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -100,6 +100,8 @@ runServer = do
100100

101101
peerSim <- makePeerSimulatorResources nullTracer undefined $ NonEmpty.fromList $ M.keys peerMap
102102

103+
incomingTMV <- newEmptyTMVarIO
104+
103105
peerServers <-
104106
for (zipMaps peerMap $ psrPeers peerSim) $ \(port, res) -> do
105107
-- Make a TMVar for the chainsync and blockfetch channels exposed through
@@ -110,7 +112,7 @@ runServer = do
110112

111113
putStrLn $ "starting server on " <> show port
112114
let sockAddr = Socket.SockAddrInet port $ Socket.tupleToHostAddress (127, 0, 0, 1)
113-
thread <- async $ run res csChannelTMV bfChannelTMV sockAddr
115+
thread <- async $ run res incomingTMV csChannelTMV bfChannelTMV sockAddr
114116
pure ((csChannelTMV, bfChannelTMV), thread)
115117

116118
-- Now, take each of the resulting TMVars. This effectively blocks until the

ouroboros-consensus-diffusion/app/conformance-test-runner/Server.hs

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -43,13 +43,14 @@ import qualified Test.Util.TestBlock as TB
4343
-- | Glue code for using just the bits from the Diffusion Layer that we need in
4444
-- this context.
4545
serve ::
46+
StrictTMVar IO SockAddr ->
4647
SockAddr ->
4748
N2N.Versions
4849
N2N.NodeToNodeVersion
4950
N2N.NodeToNodeVersionData
5051
(OuroborosApplicationWithMinimalCtx 'Mux.ResponderMode SockAddr BL.ByteString IO Void ()) ->
5152
IO Void
52-
serve sockAddr application = withIOManager \iocp ->
53+
serve incomingTV sockAddr application = withIOManager \iocp ->
5354
Server.with
5455
(Snocket.socketSnocket iocp)
5556
Snocket.makeSocketBearer
@@ -65,7 +66,7 @@ serve sockAddr application = withIOManager \iocp ->
6566
, haTimeLimits = Handshake.timeLimitsHandshake
6667
}
6768
(SomeResponderApplication <$> application)
68-
(\_ serverAsync -> wait serverAsync)
69+
(\incoming serverAsync -> atomically (tryPutTMVar incomingTV incoming) *> wait serverAsync)
6970

7071
run ::
7172
forall blk.
@@ -75,14 +76,16 @@ run ::
7576
, blk ~ TestBlock
7677
) =>
7778
PeerResources IO blk ->
79+
-- | A TMVar for the connecting peer
80+
StrictTMVar IO SockAddr ->
7881
-- | A TMVar for the chainsync channel that we will fill in once the node connects.
7982
StrictTVar IO Bool ->
8083
-- | A TMVar for the blockfetch channel that we will fill in once the node connects.
8184
StrictTVar IO Bool ->
8285
SockAddr ->
8386
IO Void
84-
run res csChanTMV bfChanTMV sockAddr = withRegistry \_registry ->
85-
serve sockAddr
87+
run res incomingTV csChanTMV bfChanTMV sockAddr = withRegistry \_registry ->
88+
serve incomingTV sockAddr
8689
$ peerSimServer @_ @TestBlock
8790
res
8891
csChanTMV

0 commit comments

Comments
 (0)