Skip to content

Commit d845064

Browse files
authored
Merge pull request #1255 from input-output-hk/era-not-supported-message
Improve message printed when era is not supported
2 parents 2a68a74 + 16f8e93 commit d845064

File tree

1 file changed

+27
-16
lines changed

1 file changed

+27
-16
lines changed

hydra-node/src/Hydra/Chain/Direct.hs

Lines changed: 27 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ import Control.Monad.Trans.Except (runExcept)
2727
import Hydra.Cardano.Api (
2828
Block (..),
2929
BlockInMode (..),
30-
CardanoEra (BabbageEra),
30+
CardanoEra (..),
3131
CardanoMode,
3232
ChainPoint,
3333
ChainTip,
@@ -259,16 +259,23 @@ newtype IntersectionNotFoundException = IntersectionNotFound
259259

260260
instance Exception IntersectionNotFoundException
261261

262-
data ChainClientException = EraNotSupportedException
263-
{ otherEraName :: Text
264-
, ledgerEraName :: Text
265-
}
262+
data EraNotSupportedException
263+
= EraNotSupportedAnymore {otherEraName :: Text}
264+
| EraNotSupportedYet {otherEraName :: Text}
266265
deriving stock (Show)
267266

268-
instance Exception ChainClientException where
267+
instance Exception EraNotSupportedException where
269268
displayException = \case
270-
EraNotSupportedException{ledgerEraName, otherEraName} ->
271-
printf "Received blocks in unsupported era %s. Please upgrade your hydra-node to era %s." otherEraName ledgerEraName
269+
EraNotSupportedAnymore{otherEraName} ->
270+
printf
271+
"Received blocks of not anymore supported era (%s). \
272+
\Please wait for your cardano-node to be fully synchronized."
273+
otherEraName
274+
EraNotSupportedYet{otherEraName} ->
275+
printf
276+
"Received blocks of not yet supported era (%s). \
277+
\Please upgrade your hydra-node."
278+
otherEraName
272279

273280
-- | The block type used in the node-to-client protocols.
274281
type BlockType = BlockInMode CardanoMode
@@ -308,13 +315,7 @@ chainSyncClient handler wallet startingPoint =
308315
ClientStNext
309316
{ recvMsgRollForward = \blockInMode _tip -> ChainSyncClient $ do
310317
case blockInMode of
311-
BlockInMode _ (Block header txs) BabbageEraInCardanoMode -> do
312-
-- Update the tiny wallet
313-
update wallet header txs
314-
-- Observe Hydra transactions
315-
onRollForward handler header txs
316-
pure clientStIdle
317-
BlockInMode _ block ConwayEraInCardanoMode -> do
318+
BlockInMode ConwayEra block _ -> do
318319
-- TODO: uses cardano-api:internal
319320
-- NOTE: we should remove this dependency once we have ShelleyBlock available
320321
-- on the normal cardano-api library.
@@ -332,7 +333,17 @@ chainSyncClient handler wallet startingPoint =
332333
-- Observe Hydra transactions
333334
onRollForward handler header txs
334335
pure clientStIdle
335-
(BlockInMode era _ _) -> throwIO $ EraNotSupportedException{ledgerEraName = show era, otherEraName = show BabbageEra}
336+
BlockInMode BabbageEra (Block header txs) _ -> do
337+
-- Update the tiny wallet
338+
update wallet header txs
339+
-- Observe Hydra transactions
340+
onRollForward handler header txs
341+
pure clientStIdle
342+
BlockInMode era@AlonzoEra _ _ -> throwIO $ EraNotSupportedAnymore{otherEraName = show era}
343+
BlockInMode era@AllegraEra _ _ -> throwIO $ EraNotSupportedAnymore{otherEraName = show era}
344+
BlockInMode era@MaryEra _ _ -> throwIO $ EraNotSupportedAnymore{otherEraName = show era}
345+
BlockInMode era@ShelleyEra _ _ -> throwIO $ EraNotSupportedAnymore{otherEraName = show era}
346+
BlockInMode era@ByronEra _ _ -> throwIO $ EraNotSupportedAnymore{otherEraName = show era}
336347
, recvMsgRollBackward = \point _tip -> ChainSyncClient $ do
337348
-- Re-initialize the tiny wallet
338349
reset wallet

0 commit comments

Comments
 (0)