Skip to content

Commit

Permalink
ouroboros-network-framework: renamed MuxPeer to MiniProtocolCb
Browse files Browse the repository at this point in the history
  • Loading branch information
coot committed Jun 2, 2023
1 parent 11870b2 commit 834e3c6
Show file tree
Hide file tree
Showing 15 changed files with 199 additions and 137 deletions.
4 changes: 2 additions & 2 deletions cardano-client/src/Cardano/Client/Subscription.hs
Expand Up @@ -9,7 +9,7 @@ module Cardano.Client.Subscription
, ConnectionId
, LocalAddress
, NodeToClientProtocols (..)
, MuxPeer (..)
, MiniProtocolCb (..)
, MuxTrace
, RunMiniProtocol (..)
, WithMuxBearer
Expand All @@ -25,7 +25,7 @@ import Network.Mux.Trace (MuxTrace, WithMuxBearer)

import Ouroboros.Network.ControlMessage (ControlMessage (..))
import Ouroboros.Network.Magic (NetworkMagic)
import Ouroboros.Network.Mux (MuxMode (..), MuxPeer (..),
import Ouroboros.Network.Mux (MuxMode (..), MiniProtocolCb (..),
OuroborosApplicationWithMinimalCtx, RunMiniProtocol (..))
import Ouroboros.Network.NodeToClient (ClientSubscriptionParams (..),
ConnectionId, LocalAddress,
Expand Down
21 changes: 14 additions & 7 deletions ouroboros-network-framework/CHANGELOG.md
Expand Up @@ -42,13 +42,20 @@
- `Ouroboros.Network.Socket.withServerNode`
- inbound governor API

* `MuxPeer` and `MuxPeerPipelined` constructors of `MuxPeer` type were removed.
Use `mkMuxPeer` and `mkMuxPeerPipelined` instead. Note that these are not
inplace replacment.

* `runMuxPeer` changed its type. It receives two arguments: the context and
`Network.Mux.Channel.Channel` rather than `Ouroboros.Network.Channel.Channel`
(no need to use `Ouroboros.Network.Channel.fromChannel`)
* `MuxPeer` changed it's kind and it was renamed to `MiniProtocolCb`, the old
type is still provided but deprecated. The `MuxPeerRaw` constructor was
renamed to `MiniProtocolCb` (the old one is still provided but deprecated).
`MuxPeer` and `MuxPeerPipelined` constructors also changed its type and are
now deprecated. Use `mkMiniProtocolCbFromPeer` and
`mkMiniProtocolCbFromPeerPipelined` instead.

Also note that even the deprecated constructors have changed their types.

* `runMuxPeer` change its type but also is now deprecated in favour of `runMiniProtocolCb`. The latter
receives two arguments: the context and `Network.Mux.Channel.Channel` rather
than `Ouroboros.Network.Channel.Channel` (no need to use
`Ouroboros.Network.Channel.fromChannel`). `runMuxPeer` accepts the context (added argument) and
`Ouroboros.Network.Channel.Channel`.

## 0.6.0.1 -- 2023-05-15

Expand Down
6 changes: 3 additions & 3 deletions ouroboros-network-framework/demo/connection-manager.hs
Expand Up @@ -337,7 +337,7 @@ withBidirectionalConnectionManager snocket makeBearer socket
InitiatorResponderMode peerAddr ByteString m () ()
reqRespInitiatorAndResponder protocolNum requestsVar =
InitiatorAndResponderProtocol
(mkMuxPeer
(mkMiniProtocolCbFromPeer
(\_ctx -> ( ("Initiator",protocolNum,) `contramap` debugTracer -- TraceSendRecv
, codecReqResp @Int @Int
, Effect $ do
Expand All @@ -351,7 +351,7 @@ withBidirectionalConnectionManager snocket makeBearer socket
pure $ reqRespClientPeer (reqRespClient reqs)
)
))
(mkMuxPeer
(mkMiniProtocolCbFromPeer
(\_ctx -> ( ("Responder",protocolNum,) `contramap` debugTracer -- TraceSendRecv
, codecReqResp @Int @Int
, Effect $ reqRespServerPeer <$> reqRespServerId
Expand Down Expand Up @@ -426,7 +426,7 @@ runInitiatorProtocols
SingInitiatorMode -> Mux.InitiatorDirectionOnly
SingInitiatorResponderMode -> Mux.InitiatorDirection)
Mux.StartEagerly
(runMuxPeer
(runMiniProtocolCb
(case miniProtocolRun ptcl of
InitiatorProtocolOnly initiator -> initiator
InitiatorAndResponderProtocol initiator _ -> initiator)
Expand Down
14 changes: 7 additions & 7 deletions ouroboros-network-framework/demo/ping-pong.hs
Expand Up @@ -125,15 +125,15 @@ clientPingPong pipelined =

pingPongInitiator | pipelined =
InitiatorProtocolOnly $
mkMuxPeerPipelined $ \_ctx ->
mkMiniProtocolCbFromPeerPipelined $ \_ctx ->
(contramap show stdoutTracer
, codecPingPong
, pingPongClientPeerPipelined (pingPongClientPipelinedMax 5)
)

| otherwise =
InitiatorProtocolOnly $
mkMuxPeer $ \_ctx ->
mkMiniProtocolCbFromPeer $ \_ctx ->
( contramap show stdoutTracer
, codecPingPong
, pingPongClientPeer (pingPongClientCount 5)
Expand Down Expand Up @@ -172,7 +172,7 @@ serverPingPong =

pingPongResponder =
ResponderProtocolOnly $
mkMuxPeer $ \_ctx ->
mkMiniProtocolCbFromPeer $ \_ctx ->
( contramap show stdoutTracer
, codecPingPong
, pingPongServerPeer pingPongServerStandard
Expand Down Expand Up @@ -232,15 +232,15 @@ clientPingPong2 =

pingpong =
InitiatorProtocolOnly $
mkMuxPeer $ \_ctx ->
mkMiniProtocolCbFromPeer $ \_ctx ->
( contramap (show . (,) (1 :: Int)) stdoutTracer
, codecPingPong
, pingPongClientPeer (pingPongClientCount 5)
)

pingpong'=
InitiatorProtocolOnly $
mkMuxPeer $ \_ctx ->
mkMiniProtocolCbFromPeer $ \_ctx ->
( contramap (show . (,) (2 :: Int)) stdoutTracer
, codecPingPong
, pingPongClientPeer (pingPongClientCount 5)
Expand Down Expand Up @@ -292,15 +292,15 @@ serverPingPong2 =

pingpong =
ResponderProtocolOnly $
mkMuxPeer $ \_ctx ->
mkMiniProtocolCbFromPeer $ \_ctx ->
( contramap (show . (,) (1 :: Int)) stdoutTracer
, codecPingPong
, pingPongServerPeer pingPongServerStandard
)

pingpong' =
ResponderProtocolOnly $
mkMuxPeer $ \_ctx ->
mkMiniProtocolCbFromPeer $ \_ctx ->
( contramap (show . (,) (2 :: Int)) stdoutTracer
, codecPingPong
, pingPongServerPeer pingPongServerStandard
Expand Down
Expand Up @@ -493,14 +493,14 @@ runResponder mux
mux (miniProtocolNum miniProtocol)
Mux.ResponderDirectionOnly
startStrategy
(runMuxPeer responder responderContext)
(runMiniProtocolCb responder responderContext)

InitiatorAndResponderProtocol _ responder ->
Mux.runMiniProtocol
mux (miniProtocolNum miniProtocol)
Mux.ResponderDirection
startStrategy
(runMuxPeer responder responderContext)
(runMiniProtocolCb responder responderContext)


--
Expand Down

0 comments on commit 834e3c6

Please sign in to comment.