Skip to content

Commit

Permalink
Remove EpochInterval and co. from BaseTypes
Browse files Browse the repository at this point in the history
Both `EpochInterval` and `addEpochInterval` was moved to `cardano-slotting`
in `cardano-base` as part of IntersectMBO/cardano-base#456.
Import them from there.
  • Loading branch information
Lucsanszky committed Feb 19, 2024
1 parent b167ad3 commit b97e379
Show file tree
Hide file tree
Showing 5 changed files with 13 additions and 21 deletions.
4 changes: 2 additions & 2 deletions libs/cardano-ledger-binary/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
# Version history for `cardano-ledger-binary`

## 1.3.0.1
## 1.3.1.0

*
* Add `EncCBOR` and `DecCBOR` instances for `EpochInterval`

## 1.3.0.0

Expand Down
4 changes: 2 additions & 2 deletions libs/cardano-ledger-binary/cardano-ledger-binary.cabal
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
cabal-version: 3.0
name: cardano-ledger-binary
version: 1.3.0.0
version: 1.3.1.0
license: Apache-2.0
maintainer: operations@iohk.io
author: IOHK
Expand Down Expand Up @@ -53,7 +53,7 @@ library
cardano-binary >=1.7,
cardano-crypto-class >=2.1,
cardano-crypto-praos >=2.1,
cardano-slotting,
cardano-slotting >=0.2,
cardano-strict-containers >=0.1.2,
cborg >=0.2.9,
containers,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ import Cardano.Ledger.Binary.Crypto
import Cardano.Ledger.Binary.Decoding.Decoder
import Cardano.Ledger.Binary.Version (Version, byronProtVer)
import Cardano.Slotting.Block (BlockNo (..))
import Cardano.Slotting.Slot (EpochNo (..), EpochSize (..), SlotNo (..), WithOrigin (..))
import Cardano.Slotting.Slot (EpochInterval (..), EpochNo (..), EpochSize (..), SlotNo (..), WithOrigin (..))
import Cardano.Slotting.Time (SystemStart (..))
import Codec.CBOR.ByteArray (ByteArray (..))
import Codec.CBOR.ByteArray.Sliced (SlicedByteArray, fromByteArray)
Expand Down Expand Up @@ -646,6 +646,8 @@ instance DecCBOR BlockNo where
decCBOR = fromPlainDecoder decode
{-# INLINE decCBOR #-}

deriving instance DecCBOR EpochInterval

--------------------------------------------------------------------------------
-- Plutus
--------------------------------------------------------------------------------
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ import Cardano.Ledger.Binary.Crypto
import Cardano.Ledger.Binary.Encoding.Encoder
import Cardano.Ledger.Binary.Version (Version, byronProtVer, getVersion64)
import Cardano.Slotting.Block (BlockNo (..))
import Cardano.Slotting.Slot (EpochNo (..), EpochSize (..), SlotNo (..), WithOrigin (..))
import Cardano.Slotting.Slot (EpochInterval (..), EpochNo (..), EpochSize (..), SlotNo (..), WithOrigin (..))
import Cardano.Slotting.Time (SystemStart (..))
import Codec.CBOR.ByteArray (ByteArray (..))
import Codec.CBOR.ByteArray.Sliced (SlicedByteArray (SBA), fromByteArray)
Expand Down Expand Up @@ -1147,6 +1147,8 @@ instance EncCBOR BlockNo where
encCBOR = fromPlainEncoding . Serialise.encode
encodedSizeExpr size = encodedSizeExpr size . fmap unBlockNo

deriving instance EncCBOR EpochInterval

--------------------------------------------------------------------------------
-- Plutus
--------------------------------------------------------------------------------
Expand Down
18 changes: 3 additions & 15 deletions libs/cardano-ledger-core/src/Cardano/Ledger/BaseTypes.hs
Original file line number Diff line number Diff line change
Expand Up @@ -53,8 +53,6 @@ module Cardano.Ledger.BaseTypes (
activeSlotLog,
module Data.Maybe.Strict,
BlocksMade (..),
EpochInterval (..),
addEpochInterval,
kindObject,

-- * Indices
Expand Down Expand Up @@ -124,10 +122,12 @@ import Cardano.Ledger.SafeHash (HashWithCrypto (..), SafeHash, SafeToHash)
import Cardano.Slotting.Block as Slotting (BlockNo (..))
import Cardano.Slotting.EpochInfo (EpochInfo, hoistEpochInfo)
import Cardano.Slotting.Slot as Slotting (
EpochInterval (..),
EpochNo (..),
EpochSize (..),
SlotNo (..),
WithOrigin (..),
addEpochInterval,
binOpEpochNo,
)
import Cardano.Slotting.Time (SystemStart)
Expand Down Expand Up @@ -169,7 +169,7 @@ import Data.Text (Text)
import qualified Data.Text as Text
import Data.Text.Encoding (encodeUtf8)
import Data.Typeable (Typeable)
import Data.Word (Word16, Word32, Word64, Word8)
import Data.Word (Word16, Word64, Word8)
import GHC.Exception.Type (Exception)
import GHC.Generics (Generic)
import GHC.Stack (HasCallStack)
Expand Down Expand Up @@ -836,18 +836,6 @@ toAnchorPairs vote@(Anchor _ _) =
instance Default Network where
def = Mainnet

-- | Denotes a positive change in the EpochNo
newtype EpochInterval = EpochInterval
{ unEpochInterval :: Word32
}
deriving (Eq, Ord, Generic)
deriving (Show) via Quiet EpochInterval
deriving newtype (NoThunks, NFData, ToJSON, FromJSON, EncCBOR, DecCBOR, ToCBOR, FromCBOR)

-- | Add a EpochInterval (a positive change) to an EpochNo to get a new EpochNo
addEpochInterval :: EpochNo -> EpochInterval -> EpochNo
addEpochInterval (EpochNo n) (EpochInterval m) = EpochNo (n + fromIntegral m)

class Inject t s where
inject :: t -> s
default inject :: t ~ s => t -> s
Expand Down

0 comments on commit b97e379

Please sign in to comment.