Skip to content

Commit

Permalink
Add PeerHandshakeFailure to ServerOutput
Browse files Browse the repository at this point in the history
  • Loading branch information
locallycompact committed Apr 29, 2024
1 parent 180199a commit d920ee5
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 0 deletions.
4 changes: 4 additions & 0 deletions hydra-node/src/Hydra/API/ServerOutput.hs
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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}
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -178,6 +181,7 @@ prepareServerOutput ServerOutputConfig{utxoInSnapshot} response =
case output response of
PeerConnected{} -> encodedResponse
PeerDisconnected{} -> encodedResponse
PeerHandshakeFailure{} -> encodedResponse
HeadIsInitializing{} -> encodedResponse
Committed{} -> encodedResponse
HeadIsOpen{} -> encodedResponse
Expand Down
2 changes: 2 additions & 0 deletions hydra-node/src/Hydra/HeadLogic.hs
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
2 changes: 2 additions & 0 deletions hydra-node/src/Hydra/Network/Message.hs
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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)

Expand Down

0 comments on commit d920ee5

Please sign in to comment.