Skip to content

Commit 00bf3bf

Browse files
committed
Use decSharePlusLensCBOR instead of explicitly modifying the interns
1 parent 075454f commit 00bf3bf

File tree

1 file changed

+4
-14
lines changed
  • libs/cardano-ledger-core/src/Cardano/Ledger/State

1 file changed

+4
-14
lines changed

libs/cardano-ledger-core/src/Cardano/Ledger/State/CertState.hs

Lines changed: 4 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,6 @@ import Cardano.Ledger.Binary (
6464
decodeRecordNamed,
6565
decodeRecordNamedT,
6666
encodeListLen,
67-
internsFromMap,
6867
internsFromSet,
6968
toMemptyLens,
7069
)
@@ -80,7 +79,6 @@ import Cardano.Ledger.State.Account
8079
import Cardano.Ledger.State.StakePool (StakePoolState (..))
8180
import Control.DeepSeq (NFData (..))
8281
import Control.Monad.Trans
83-
import Control.Monad.Trans.State.Strict (get, put)
8482
import Data.Aeson (ToJSON (..), object, (.=))
8583
import Data.Default (Default (def))
8684
import qualified Data.Foldable as F
@@ -252,18 +250,10 @@ instance DecShareCBOR (PState era) where
252250
type Share (PState era) = (Interns (VRFVerKeyHash 'StakePoolVRF), Interns (KeyHash 'StakePool))
253251

254252
decSharePlusCBOR = decodeRecordNamedT "PState" (const 4) $ do
255-
(vrfKh, kh) <- get
256-
psVRFKeyHashes <- lift $ decShareCBOR (vrfKh, mempty)
257-
psStakePools <- lift $ decShareCBOR (kh, mempty)
258-
psFutureStakePools <- lift $ decShareCBOR (kh, mempty)
259-
psRetiring <- lift $ decShareCBOR (kh, mempty)
260-
put
261-
( internsFromMap psVRFKeyHashes <> vrfKh
262-
, internsFromMap psStakePools
263-
<> internsFromMap psFutureStakePools
264-
<> internsFromMap psRetiring
265-
<> kh
266-
)
253+
psVRFKeyHashes <- decSharePlusLensCBOR (toMemptyLens _1 _1)
254+
psStakePools <- decSharePlusLensCBOR (toMemptyLens _1 _2)
255+
psFutureStakePools <- decSharePlusLensCBOR (toMemptyLens _1 _2)
256+
psRetiring <- decSharePlusLensCBOR (toMemptyLens _1 _2)
267257
pure PState {psVRFKeyHashes, psStakePools, psFutureStakePools, psRetiring}
268258

269259
instance (Era era, DecShareCBOR (PState era)) => DecCBOR (PState era) where

0 commit comments

Comments
 (0)