Skip to content

Commit

Permalink
Updated NodeToNode and NodeToClient 'networkErrorPolicy'
Browse files Browse the repository at this point in the history
  • Loading branch information
coot committed Jul 6, 2020
1 parent ea84fb5 commit 5c2a343
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 6 deletions.
7 changes: 4 additions & 3 deletions ouroboros-network/src/Ouroboros/Network/NodeToClient.hs
Expand Up @@ -104,7 +104,8 @@ import Network.Mux (WithMuxBearer (..))

import Ouroboros.Network.Codec
import Ouroboros.Network.Driver (TraceSendRecv(..))
import Ouroboros.Network.Driver.Limits (ProtocolLimitFailure)
import Ouroboros.Network.Driver.Simple (DecoderFailure)
import Ouroboros.Network.Driver.Limits (ProtocolLimitFailure (..))
import Ouroboros.Network.Mux
import Ouroboros.Network.NodeToClient.Version
import Ouroboros.Network.ErrorPolicy
Expand Down Expand Up @@ -563,8 +564,8 @@ networkErrorPolicies = ErrorPolicies

-- deserialisation failure of a message from a trusted node
, ErrorPolicy
$ \(_ :: CBOR.DeserialiseFailure)
-> Just ourBug
$ \(_ :: DecoderFailure CBOR.DeserialiseFailure)
-> Just ourBug

, ErrorPolicy
$ \(e :: MuxError)
Expand Down
13 changes: 10 additions & 3 deletions ouroboros-network/src/Ouroboros/Network/NodeToNode.hs
Expand Up @@ -107,7 +107,8 @@ import qualified Network.Socket as Socket

import Ouroboros.Network.Codec
import Ouroboros.Network.Driver (TraceSendRecv(..))
import Ouroboros.Network.Driver.Limits (ProtocolLimitFailure)
import Ouroboros.Network.Driver.Simple (DecoderFailure)
import Ouroboros.Network.Driver.Limits (ProtocolLimitFailure (..))
import Ouroboros.Network.IOManager
import Ouroboros.Network.Mux
import Ouroboros.Network.NodeToNode.Version
Expand Down Expand Up @@ -614,8 +615,14 @@ remoteNetworkErrorPolicy = ErrorPolicies {
-- producer, as it's likely that the other side of the connection
-- will return grabage as well.
, ErrorPolicy
$ \(_ :: CBOR.DeserialiseFailure)
-> Just theyBuggyOrEvil
$ \(_ :: DecoderFailure CBOR.DeserialiseFailure)
-> Just theyBuggyOrEvil

, ErrorPolicy
$ \(msg :: ProtocolLimitFailure)
-> case msg of
ExceededSizeLimit{} -> Just theyBuggyOrEvil
ExceededTimeLimit{} -> Just (SuspendConsumer shortDelay)

-- the connection was unexpectedly closed, we suspend the peer for
-- a 'shortDelay'
Expand Down

0 comments on commit 5c2a343

Please sign in to comment.