diff --git a/hydra-node/src/Hydra/API/ServerOutput.hs b/hydra-node/src/Hydra/API/ServerOutput.hs index a7856b6a0bc..07da5febb64 100644 --- a/hydra-node/src/Hydra/API/ServerOutput.hs +++ b/hydra-node/src/Hydra/API/ServerOutput.hs @@ -20,6 +20,7 @@ import Hydra.OnChainId (OnChainId) import Hydra.Party (Party) import Hydra.Prelude hiding (seq) import Hydra.Snapshot (Snapshot (utxo), SnapshotNumber) +import Hydra.Network.Ouroboros (Host) -- | The type of messages sent to clients by the 'Hydra.API.Server'. data TimedServerOutput tx = TimedServerOutput @@ -53,6 +54,7 @@ instance IsChainState tx => FromJSON (TimedServerOutput tx) where data ServerOutput tx = PeerConnected {peer :: NodeId} | PeerDisconnected {peer :: NodeId} + | PeerHandshakeFailure {host :: Host} | HeadIsInitializing {headId :: HeadId, parties :: [Party]} | Committed {headId :: HeadId, party :: Party, utxo :: UTxOType tx} | HeadIsOpen {headId :: HeadId, utxo :: UTxOType tx} @@ -129,6 +131,7 @@ instance shrink = \case PeerConnected p -> PeerConnected <$> shrink p PeerDisconnected p -> PeerDisconnected <$> shrink p + PeerHandshakeFailure p -> PeerHandshakeFailure <$> shrink p HeadIsInitializing headId xs -> HeadIsInitializing <$> shrink headId <*> shrink xs Committed headId p u -> Committed <$> shrink headId <*> shrink p <*> shrink u HeadIsOpen headId u -> HeadIsOpen <$> shrink headId <*> shrink u @@ -178,6 +181,7 @@ prepareServerOutput ServerOutputConfig{utxoInSnapshot} response = case output response of PeerConnected{} -> encodedResponse PeerDisconnected{} -> encodedResponse + PeerHandshakeFailure{} -> encodedResponse HeadIsInitializing{} -> encodedResponse Committed{} -> encodedResponse HeadIsOpen{} -> encodedResponse diff --git a/hydra-node/src/Hydra/HeadLogic.hs b/hydra-node/src/Hydra/HeadLogic.hs index a156af84686..1a02907fbf8 100644 --- a/hydra-node/src/Hydra/HeadLogic.hs +++ b/hydra-node/src/Hydra/HeadLogic.hs @@ -102,6 +102,8 @@ onConnectionEvent = \case causes [ClientEffect (ServerOutput.PeerConnected nodeId)] Disconnected{nodeId} -> causes [ClientEffect (ServerOutput.PeerDisconnected nodeId)] + HandshakeFailure{host} -> + causes [ClientEffect (ServerOutput.PeerHandshakeFailure host)] -- * The Coordinated Head protocol diff --git a/hydra-node/src/Hydra/Network/Message.hs b/hydra-node/src/Hydra/Network/Message.hs index 0e0210a43ca..02369d27702 100644 --- a/hydra-node/src/Hydra/Network/Message.hs +++ b/hydra-node/src/Hydra/Network/Message.hs @@ -11,6 +11,7 @@ import Hydra.Ledger (IsTx (TxIdType), UTxOType) import Hydra.Network (NodeId) import Hydra.Party (Party) import Hydra.Snapshot (Snapshot, SnapshotNumber) +import Hydra.Network.Ouroboros (Host) data NetworkEvent msg = ConnectivityEvent Connectivity @@ -24,6 +25,7 @@ instance Arbitrary msg => Arbitrary (NetworkEvent msg) where data Connectivity = Connected {nodeId :: NodeId} | Disconnected {nodeId :: NodeId} + | HandshakeFailure {host :: Host} deriving stock (Generic, Eq, Show) deriving anyclass (ToJSON, FromJSON)