Skip to content

Commit

Permalink
Drop network-mux dep on cborg and typed-protocols.
Browse files Browse the repository at this point in the history
The cborg dep is not used at all.

To drop the dep on typed-protocols we just had to make sure network-mux
always uses the Channel type from network-mux rather than the one from
typed-protocols.

The network-mux tests still use cborg and typed-protocols but that's ok.
  • Loading branch information
dcoutts committed Jan 16, 2020
1 parent 90c1ba8 commit c527b00
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 15 deletions.
2 changes: 0 additions & 2 deletions network-mux/network-mux.cabal
Expand Up @@ -26,14 +26,12 @@ Flag ipv6

library
build-depends: base >=4.9 && <4.13,
typed-protocols >=0.1 && <0.2,
io-sim-classes >=0.1 && <0.2,
contra-tracer >=0.1 && <0.2,

array >=0.5 && <0.6,
binary >=0.8 && <0.9,
bytestring >=0.10 && <0.11,
cborg >=0.2.1 && <0.3,
containers,
network,
process >=1.6 && <1.7,
Expand Down
15 changes: 6 additions & 9 deletions network-mux/src/Network/Mux/Types.hs
Expand Up @@ -34,8 +34,8 @@ import qualified Data.ByteString.Lazy as BL

import Control.Monad.Class.MonadTime

import Network.Mux.Channel (Channel)
import qualified Network.TypedProtocol.Channel as TypedProtocol
import Network.Mux.Channel (Channel(..))


newtype RemoteClockModel
= RemoteClockModel { unRemoteClockModel :: Word32 }
Expand Down Expand Up @@ -186,16 +186,13 @@ data MuxBearer m = MuxBearer {
muxBearerAsControlChannel
:: MuxBearer IO
-> MiniProtocolMode
-> TypedProtocol.Channel IO BL.ByteString
-> Channel IO
muxBearerAsControlChannel bearer mode =
TypedProtocol.Channel {
TypedProtocol.send = send,
TypedProtocol.recv = recv
Channel {
send = \blob -> void $ write bearer (wrap blob),
recv = Just . msBlob . fst <$> read bearer
}
where
send blob = void $ write bearer (wrap blob)
recv = Just . msBlob . fst <$> read bearer

-- wrap a 'ByteString' as 'MuxSDU'
wrap :: BL.ByteString -> MuxSDU
wrap blob = MuxSDU {
Expand Down
2 changes: 0 additions & 2 deletions nix/.stack.nix/network-mux.nix

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 3 additions & 2 deletions ouroboros-network/src/Ouroboros/Network/Socket.hs
Expand Up @@ -86,6 +86,7 @@ import Ouroboros.Network.Protocol.Handshake.Type
import Ouroboros.Network.Protocol.Handshake.Version
import Ouroboros.Network.Protocol.Handshake.Codec
import Ouroboros.Network.Mux
import Ouroboros.Network.Channel
import qualified Ouroboros.Network.Server.Socket as Server
import Ouroboros.Network.Server.ConnectionTable

Expand Down Expand Up @@ -232,7 +233,7 @@ connectToNode' versionDataCodec NetworkConnectTracers {nctMuxTracer, nctHandshak
nctHandshakeTracer
codecHandshake
connectionId
(Mx.muxBearerAsControlChannel bearer Mx.ModeInitiator)
(fromChannel (Mx.muxBearerAsControlChannel bearer Mx.ModeInitiator))
(handshakeClientPeer versionDataCodec versions)
ts_end <- getMonotonicTime
case mapp of
Expand Down Expand Up @@ -310,7 +311,7 @@ beginConnection muxTracer handshakeTracer versionDataCodec acceptVersion fn t ad
handshakeTracer
codecHandshake
peerid
(Mx.muxBearerAsControlChannel bearer Mx.ModeResponder)
(fromChannel (Mx.muxBearerAsControlChannel bearer Mx.ModeResponder))
(handshakeServerPeer versionDataCodec acceptVersion versions)
case mapp of
Left err -> do
Expand Down

0 comments on commit c527b00

Please sign in to comment.