Skip to content

Commit

Permalink
handshake: ProtocolTimeLmits in ouroboros-network
Browse files Browse the repository at this point in the history
Use 'timeLimitsHandshake' for 'node-to-node' (10s timeout) and
'noTimeLimitsHandshake' for node-to-client' protocols (no timeout).
  • Loading branch information
coot committed Mar 12, 2021
1 parent 65e7688 commit 160826a
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 1 deletion.
4 changes: 4 additions & 0 deletions ouroboros-network/demo/chain-sync.hs
Original file line number Diff line number Diff line change
Expand Up @@ -154,6 +154,7 @@ clientChainSync sockPaths = withIOManager $ \iocp ->
connectToNode
(localSnocket iocp sockPath)
unversionedHandshakeCodec
noTimeLimitsHandshake
(cborTermVersionDataCodec unversionedProtocolDataCodec)
nullNetworkConnectTracers
acceptableVersion
Expand Down Expand Up @@ -187,6 +188,7 @@ serverChainSync sockAddr = withIOManager $ \iocp -> do
(AcceptedConnectionsLimit maxBound maxBound 0)
(localAddressFromPath sockAddr)
unversionedHandshakeCodec
noTimeLimitsHandshake
(cborTermVersionDataCodec unversionedProtocolDataCodec)
acceptableVersion
(simpleSingletonVersions
Expand Down Expand Up @@ -358,6 +360,7 @@ clientBlockFetch sockAddrs = withIOManager $ \iocp -> do
connectToNode
(localSnocket iocp defaultLocalSocketAddrPath)
unversionedHandshakeCodec
noTimeLimitsHandshake
(cborTermVersionDataCodec unversionedProtocolDataCodec)
nullNetworkConnectTracers
acceptableVersion
Expand Down Expand Up @@ -413,6 +416,7 @@ serverBlockFetch sockAddr = withIOManager $ \iocp -> do
(AcceptedConnectionsLimit maxBound maxBound 0)
(localAddressFromPath sockAddr)
unversionedHandshakeCodec
noTimeLimitsHandshake
(cborTermVersionDataCodec unversionedProtocolDataCodec)
acceptableVersion
(simpleSingletonVersions
Expand Down
3 changes: 3 additions & 0 deletions ouroboros-network/src/Ouroboros/Network/NodeToClient.hs
Original file line number Diff line number Diff line change
Expand Up @@ -240,6 +240,7 @@ connectTo
connectTo snocket tracers versions path =
connectToNode snocket
nodeToClientHandshakeCodec
noTimeLimitsHandshake
(cborTermVersionDataCodec nodeToClientCodecCBORTerm)
tracers
acceptableVersion
Expand Down Expand Up @@ -270,6 +271,7 @@ withServer sn tracers networkState sd versions errPolicies =
(AcceptedConnectionsLimit maxBound maxBound 0)
sd
nodeToClientHandshakeCodec
noTimeLimitsHandshake
(cborTermVersionDataCodec nodeToClientCodecCBORTerm)
acceptableVersion
(SomeResponderApplication <$> versions)
Expand Down Expand Up @@ -316,6 +318,7 @@ ncSubscriptionWorker
(connectToNode'
sn
nodeToClientHandshakeCodec
noTimeLimitsHandshake
(cborTermVersionDataCodec nodeToClientCodecCBORTerm)
(NetworkConnectTracers nsMuxTracer nsHandshakeTracer)
acceptableVersion
Expand Down
5 changes: 4 additions & 1 deletion ouroboros-network/src/Ouroboros/Network/NodeToNode.hs
Original file line number Diff line number Diff line change
Expand Up @@ -402,7 +402,7 @@ connectTo
-> Socket.SockAddr
-> IO ()
connectTo sn tr =
connectToNode sn nodeToNodeHandshakeCodec
connectToNode sn nodeToNodeHandshakeCodec timeLimitsHandshake
(cborTermVersionDataCodec nodeToNodeCodecCBORTerm)
tr acceptableVersion

Expand Down Expand Up @@ -434,6 +434,7 @@ withServer sn tracers networkState acceptedConnectionsLimit sd versions errPolic
acceptedConnectionsLimit
sd
nodeToNodeHandshakeCodec
timeLimitsHandshake
(cborTermVersionDataCodec nodeToNodeCodecCBORTerm)
acceptableVersion
(SomeResponderApplication <$> versions)
Expand Down Expand Up @@ -476,6 +477,7 @@ ipSubscriptionWorker
(connectToNode'
sn
nodeToNodeHandshakeCodec
timeLimitsHandshake
(cborTermVersionDataCodec nodeToNodeCodecCBORTerm)
(NetworkConnectTracers nsMuxTracer nsHandshakeTracer)
acceptableVersion
Expand Down Expand Up @@ -519,6 +521,7 @@ dnsSubscriptionWorker
(connectToNode'
sn
nodeToNodeHandshakeCodec
timeLimitsHandshake
(cborTermVersionDataCodec nodeToNodeCodecCBORTerm)
(NetworkConnectTracers ndstMuxTracer ndstHandshakeTracer)
acceptableVersion
Expand Down
4 changes: 4 additions & 0 deletions ouroboros-network/test/Test/Socket.hs
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,8 @@ import Ouroboros.Network.Protocol.Handshake.Codec
(cborTermVersionDataCodec)
import Ouroboros.Network.Protocol.Handshake.Version
(acceptableVersion)
import Ouroboros.Network.Protocol.Handshake.Codec
(noTimeLimitsHandshake)
import Ouroboros.Network.Testing.Serialise
import Ouroboros.Network.Util.ShowProxy

Expand Down Expand Up @@ -157,6 +159,7 @@ demo chain0 updates = withIOManager $ \iocp -> do
(AcceptedConnectionsLimit maxBound maxBound 0)
producerAddress
nodeToNodeHandshakeCodec
noTimeLimitsHandshake
(cborTermVersionDataCodec nodeToNodeCodecCBORTerm)
acceptableVersion
(simpleSingletonVersions
Expand All @@ -171,6 +174,7 @@ demo chain0 updates = withIOManager $ \iocp -> do
(connectToNode
(socketSnocket iocp)
nodeToNodeHandshakeCodec
noTimeLimitsHandshake
(cborTermVersionDataCodec nodeToNodeCodecCBORTerm)
nullNetworkConnectTracers
acceptableVersion
Expand Down

0 comments on commit 160826a

Please sign in to comment.