Skip to content

Commit

Permalink
Move bBodySize into Cardano.Ledger.Core
Browse files Browse the repository at this point in the history
  • Loading branch information
lehins committed Mar 30, 2023
1 parent b006a60 commit c444926
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 7 deletions.
2 changes: 1 addition & 1 deletion eras/alonzo/impl/src/Cardano/Ledger/Alonzo/Rules/Bbody.hs
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ import Cardano.Ledger.Block (Block (..))
import Cardano.Ledger.Core
import qualified Cardano.Ledger.Era as Era
import Cardano.Ledger.Keys (DSignable, Hash, coerceKeyRole)
import Cardano.Ledger.Shelley.BlockChain (bBodySize, incrBlocks)
import Cardano.Ledger.Shelley.BlockChain (incrBlocks)
import Cardano.Ledger.Shelley.LedgerState (LedgerState)
import Cardano.Ledger.Shelley.Rules (
BbodyEnv (..),
Expand Down
6 changes: 0 additions & 6 deletions eras/shelley/impl/src/Cardano/Ledger/Shelley/BlockChain.hs
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,6 @@ import qualified Cardano.Crypto.Hash.Class as Hash
import Cardano.Ledger.BaseTypes (
BlocksMade (..),
Nonce (..),
ProtVer (..),
StrictMaybe (..),
mkNonceFromNumber,
strictMaybeToMaybe,
Expand All @@ -48,7 +47,6 @@ import Cardano.Ledger.Binary (
encodeFoldableMapEncoder,
encodePreEncoded,
serialize,
serialize',
withSlice,
)
import Cardano.Ledger.Core
Expand All @@ -60,7 +58,6 @@ import Cardano.Ledger.Shelley.Tx (ShelleyTx, segwitTx)
import Cardano.Ledger.Slot (SlotNo (..))
import Control.Monad (unless)
import Data.ByteString (ByteString)
import qualified Data.ByteString.Char8 as BS
import qualified Data.ByteString.Lazy as BSL
import Data.Coerce (coerce)
import Data.Map.Strict (Map)
Expand Down Expand Up @@ -248,9 +245,6 @@ txSeqDecoder lax = do
instance EraTx era => DecCBOR (Annotator (ShelleyTxSeq era)) where
decCBOR = txSeqDecoder False

bBodySize :: forall era. EraSegWits era => ProtVer -> TxSeq era -> Int
bBodySize (ProtVer v _) = BS.length . serialize' v . encCBORGroup

slotToNonce :: SlotNo -> Nonce
slotToNonce (SlotNo s) = mkNonceFromNumber s

Expand Down
1 change: 1 addition & 0 deletions libs/cardano-ledger-core/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
* Add `hashScriptTxWitsL`
* Remove custom `Fail` type, in favor of
[`FailT`](https://hackage.haskell.org/package/FailT) package
* Move `bBodySize` into `Cardano.Ledger.Core`

### `testlib`

Expand Down
6 changes: 6 additions & 0 deletions libs/cardano-ledger-core/src/Cardano/Ledger/Core.hs
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ module Cardano.Ledger.Core (
Era (..),
-- $segWit
EraSegWits (..),
bBodySize,

-- * Phases
Phase (..),
Expand Down Expand Up @@ -89,7 +90,9 @@ import Cardano.Ledger.Binary (
Interns,
Sized (sizedValue),
ToCBOR,
encCBORGroup,
mkSized,
serialize',
)
import Cardano.Ledger.Coin (Coin)
import Cardano.Ledger.Compactible (Compactible (..))
Expand Down Expand Up @@ -501,6 +504,9 @@ class
-- | The number of segregated components
numSegComponents :: Word64

bBodySize :: forall era. EraSegWits era => ProtVer -> TxSeq era -> Int
bBodySize (ProtVer v _) = BS.length . serialize' v . encCBORGroup

-- ====================================================
-- Reflecting the phase of scripts into types
-- ====================================================
Expand Down

0 comments on commit c444926

Please sign in to comment.