Skip to content
Permalink
Browse files

Renamed connectTo

Ouroboros.Network.Socket.connectToNode (to match with withServerNode),
and connectTo and withServer in Ouroboros.Network.NodeToNode
  • Loading branch information...
coot committed Jun 12, 2019
1 parent 87566ea commit 28a3b29d8bcc7030e4c0a4eefb30fad92b4e271c
@@ -436,7 +436,7 @@ runClient tracer clientOptions genesisConfig epochSlots db = case clientOptions
addrInfosLocal <- Network.getAddrInfo (Just addrInfoHints) (Just "127.0.0.1") (Just "0")
addrInfosRemote <- Network.getAddrInfo (Just addrInfoHints) (Just host) (Just port)
case (addrInfosLocal, addrInfosRemote) of
(addrInfoLocal : _, addrInfoRemote : _) -> connectTo
(addrInfoLocal : _, addrInfoRemote : _) -> connectToNode
encodeTerm
decodeTerm
(initiatorVersions epochSlots chainSyncClient)
@@ -149,7 +149,7 @@ main = do
stopCondition = const (pure Nothing)
tracer = contramap (\txt -> ("", Info, txt)) trace
client = Client.chainSyncClient (clientFold tracer genesisConfig stopCondition cvs)
connectTo
connectToNode
encodeTerm
decodeTerm
(initiatorVersions epochSlots client)
@@ -139,7 +139,7 @@ instance MiniProtocolLimits DemoProtocol0 where

clientPingPong :: Bool -> IO ()
clientPingPong pipelined =
connectTo
connectToNode
(\(DictVersion codec) -> encodeTerm codec)
(\(DictVersion codec) -> decodeTerm codec)
(simpleSingletonVersions (0::Int) (NodeToNodeVersionData 0) (DictVersion nodeToNodeCodecCBORTerm) muxApplication)
@@ -220,7 +220,7 @@ instance MiniProtocolLimits DemoProtocol1 where

clientPingPong2 :: IO ()
clientPingPong2 =
connectTo
connectToNode
(\(DictVersion codec) -> encodeTerm codec)
(\(DictVersion codec) -> decodeTerm codec)
(simpleSingletonVersions (0::Int) (NodeToNodeVersionData 0) (DictVersion nodeToNodeCodecCBORTerm) muxApplication)
@@ -311,7 +311,7 @@ instance MiniProtocolLimits DemoProtocol2 where
clientChainSync :: [FilePath] -> IO ()
clientChainSync sockAddrs =
forConcurrently_ sockAddrs $ \sockAddr ->
connectTo
connectToNode
(\(DictVersion codec) -> encodeTerm codec)
(\(DictVersion codec) -> decodeTerm codec)
(simpleSingletonVersions (0::Int) (NodeToNodeVersionData 0) (DictVersion nodeToNodeCodecCBORTerm) muxApplication)
@@ -475,7 +475,7 @@ clientBlockFetch sockAddrs = do

peerAsyncs <- sequence
[ async $
connectTo
connectToNode
(\(DictVersion codec) -> encodeTerm codec)
(\(DictVersion codec) -> decodeTerm codec)
(simpleSingletonVersions (0::Int) (NodeToNodeVersionData 0) (DictVersion nodeToNodeCodecCBORTerm) (muxApplication sockAddr))
@@ -15,8 +15,8 @@ module Ouroboros.Network.NodeToNode (
, DictVersion (..)
, nodeToNodeCodecCBORTerm

, nodeToNodeConnectTo
, withServerNodeToNode
, connectTo
, withServer

-- * Re-exports
, AnyMuxResponderApp (..)
@@ -118,30 +118,30 @@ nodeToNodeCodecCBORTerm = CodecCBORTerm {encodeTerm, decodeTerm}


-- |
-- A specialised version of @'Ouroboros.Network.Socket.connectTo'@.
-- A specialised version of @'Ouroboros.Network.Socket.connectToNode'@.
--
nodeToNodeConnectTo
connectTo
:: Versions NodeToNodeVersion
DictVersion
(MuxApplication InitiatorApp NodeToNodeProtocols IO BL.ByteString a b)
-> Maybe Socket.AddrInfo
-> Socket.AddrInfo
-> IO ()
nodeToNodeConnectTo =
connectTo
connectTo =
connectToNode
(\(DictVersion codec) -> encodeTerm codec)
(\(DictVersion codec) -> decodeTerm codec)

-- |
-- A specialised version of @'Ouroboros.Network.Socket.withServerNode'@
--
withServerNodeToNode
withServer
:: Socket.AddrInfo
-> (forall vData. DictVersion vData -> vData -> vData -> Accept)
-> Versions NodeToNodeVersion DictVersion (AnyMuxResponderApp NodeToNodeProtocols IO BL.ByteString)
-> (Async () -> IO t)
-> IO t
withServerNodeToNode addr =
withServer addr =
withServerNode
addr
(\(DictVersion codec) -> encodeTerm codec)
@@ -13,7 +13,7 @@ module Ouroboros.Network.Socket (
AnyMuxResponderApp (..)
, withServerNode
, withSimpleServerNode
, connectTo
, connectToNode

-- * Helper function for creating servers
, socketAsMuxBearer
@@ -154,7 +154,7 @@ hexDump buf out = hexDump (BL.tail buf) (out ++ printf "0x%02x " (BL.head buf))
-- remote peer. It must fit into @'maxTransmissionUnit'@ (~5k bytes).
--
-- Exceptions thrown by @'MuxApplication'@ are rethrown by @'connectTo'@.
connectTo
connectToNode
:: forall ptcl vNumber extra a b.
( Mx.ProtocolEnum ptcl
, Ord ptcl
@@ -177,7 +177,7 @@ connectTo
-> Socket.AddrInfo
-- ^ remote address
-> IO ()
connectTo encodeData decodeData versions localAddr remoteAddr =
connectToNode encodeData decodeData versions localAddr remoteAddr =
bracket
(Socket.socket (Socket.addrFamily remoteAddr) Socket.Stream Socket.defaultProtocol)
Socket.close
@@ -185,7 +185,7 @@ prop_socket_send_recv initiatorAddr responderAddr f xs = do
(\(DictVersion _) -> acceptEq)
(simpleSingletonVersions NodeToNodeV_1 (NodeToNodeVersionData 0) (DictVersion nodeToNodeCodecCBORTerm) responderApp)
$ \_ -> do
connectTo
connectToNode
(\(DictVersion codec) -> encodeTerm codec)
(\(DictVersion codec) -> decodeTerm codec)
(simpleSingletonVersions NodeToNodeV_1 (NodeToNodeVersionData 0) (DictVersion nodeToNodeCodecCBORTerm) initiatorApp)
@@ -272,7 +272,7 @@ prop_socket_client_connect_error _ xs = ioProperty $ do


(res :: Either IOException Bool)
<- try $ False <$ connectTo
<- try $ False <$ connectToNode
(\(DictVersion codec) -> encodeTerm codec)
(\(DictVersion codec) -> decodeTerm codec)
(simpleSingletonVersions (0::Int) (NodeToNodeVersionData 0) (DictVersion nodeToNodeCodecCBORTerm) app)
@@ -325,7 +325,7 @@ demo chain0 updates = do
(simpleSingletonVersions (0::Int) (NodeToNodeVersionData 0) (DictVersion nodeToNodeCodecCBORTerm) responderApp)
$ \_ -> do
withAsync
(connectTo
(connectToNode
(\(DictVersion codec) -> encodeTerm codec)
(\(DictVersion codec) -> decodeTerm codec)
(simpleSingletonVersions (0::Int) (NodeToNodeVersionData 0) (DictVersion nodeToNodeCodecCBORTerm) initiatorApp)

0 comments on commit 28a3b29

Please sign in to comment.
You can’t perform that action at this time.