@@ -27,7 +27,7 @@ import Control.Monad.Trans.Except (runExcept)
27
27
import Hydra.Cardano.Api (
28
28
Block (.. ),
29
29
BlockInMode (.. ),
30
- CardanoEra (BabbageEra ),
30
+ CardanoEra (.. ),
31
31
CardanoMode ,
32
32
ChainPoint ,
33
33
ChainTip ,
@@ -259,16 +259,23 @@ newtype IntersectionNotFoundException = IntersectionNotFound
259
259
260
260
instance Exception IntersectionNotFoundException
261
261
262
- data ChainClientException = EraNotSupportedException
263
- { otherEraName :: Text
264
- , ledgerEraName :: Text
265
- }
262
+ data EraNotSupportedException
263
+ = EraNotSupportedAnymore { otherEraName :: Text }
264
+ | EraNotSupportedYet { otherEraName :: Text }
266
265
deriving stock (Show )
267
266
268
- instance Exception ChainClientException where
267
+ instance Exception EraNotSupportedException where
269
268
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
272
279
273
280
-- | The block type used in the node-to-client protocols.
274
281
type BlockType = BlockInMode CardanoMode
@@ -308,13 +315,7 @@ chainSyncClient handler wallet startingPoint =
308
315
ClientStNext
309
316
{ recvMsgRollForward = \ blockInMode _tip -> ChainSyncClient $ do
310
317
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
318
319
-- TODO: uses cardano-api:internal
319
320
-- NOTE: we should remove this dependency once we have ShelleyBlock available
320
321
-- on the normal cardano-api library.
@@ -332,7 +333,17 @@ chainSyncClient handler wallet startingPoint =
332
333
-- Observe Hydra transactions
333
334
onRollForward handler header txs
334
335
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}
336
347
, recvMsgRollBackward = \ point _tip -> ChainSyncClient $ do
337
348
-- Re-initialize the tiny wallet
338
349
reset wallet
0 commit comments