-
Notifications
You must be signed in to change notification settings - Fork 158
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add non-trivial TranslationContext for Shelley, remove TranslateEra *…
… ShelleyGenesis instances To support the ouroboros-network PR here: IntersectMBO/ouroboros-network#4091
- Loading branch information
Showing
13 changed files
with
112 additions
and
127 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
46 changes: 46 additions & 0 deletions
46
eras/shelley/impl/src/Cardano/Ledger/Shelley/Translation.hs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
{-# LANGUAGE DataKinds #-} | ||
{-# LANGUAGE DeriveAnyClass #-} | ||
{-# LANGUAGE DeriveGeneric #-} | ||
{-# LANGUAGE StandaloneDeriving #-} | ||
{-# LANGUAGE TypeFamilies #-} | ||
{-# LANGUAGE NamedFieldPuns #-} | ||
module Cardano.Ledger.Shelley.Translation where | ||
|
||
import Cardano.Ledger.Shelley.Era (ShelleyEra) | ||
import Cardano.Ledger.Core (TranslationContext, Era, Crypto) | ||
import Cardano.Ledger.Shelley.PParams (ShelleyPParams, emptyPParams) | ||
import Cardano.Ledger.Shelley.Genesis (ShelleyGenesis (..)) | ||
import Cardano.Ledger.Keys | ||
import Data.Map (Map) | ||
import qualified Data.Map as Map | ||
import GHC.Generics (Generic) | ||
import GHC.Word (Word64) | ||
import NoThunks.Class (NoThunks (..)) | ||
|
||
-- | Required data to translate a Byron ledger into a Shelley ledger. | ||
data FromByronTranslationContext era = FromByronTranslationContext { | ||
fbtcGenDelegs :: !(Map (KeyHash 'Genesis (Crypto era)) (GenDelegPair (Crypto era))) | ||
, fbtcProtocolParams :: !(ShelleyPParams era) | ||
, fbtcMaxLovelaceSupply :: !Word64 | ||
} deriving (Eq, Show, Generic) | ||
|
||
-- | Trivial FromByronTranslationContext value, for use in cases where we do not need | ||
-- to translate from Byron to Shelley. | ||
emptyFromByronTranslationContext :: FromByronTranslationContext era | ||
emptyFromByronTranslationContext = FromByronTranslationContext { | ||
fbtcGenDelegs = Map.empty | ||
, fbtcMaxLovelaceSupply = 0 | ||
, fbtcProtocolParams = emptyPParams | ||
} | ||
|
||
toFromByronTranslationContext :: ShelleyGenesis era -> FromByronTranslationContext era | ||
toFromByronTranslationContext ShelleyGenesis {sgGenDelegs, sgMaxLovelaceSupply, sgProtocolParams} = | ||
FromByronTranslationContext { | ||
fbtcGenDelegs = sgGenDelegs | ||
, fbtcProtocolParams = sgProtocolParams | ||
, fbtcMaxLovelaceSupply = sgMaxLovelaceSupply | ||
} | ||
|
||
deriving instance Era era => NoThunks (FromByronTranslationContext era) | ||
|
||
type instance TranslationContext (ShelleyEra c) = FromByronTranslationContext (ShelleyEra c) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters