Skip to content

Commit

Permalink
[alonzo] - TxDats
Browse files Browse the repository at this point in the history
  • Loading branch information
teodanciu committed Jan 29, 2025
1 parent 408490b commit 0a26a78
Showing 1 changed file with 11 additions and 1 deletion.
12 changes: 11 additions & 1 deletion eras/alonzo/impl/src/Cardano/Ledger/Alonzo/TxWits.hs
Original file line number Diff line number Diff line change
Expand Up @@ -333,12 +333,22 @@ instance Era era => DecCBOR (Annotator (TxDatsRaw era)) where
(mapTraverseableDecoderA (decodeList decCBOR) (TxDatsRaw . Map.fromElems hashData))
{-# INLINE decCBOR #-}

instance Era era => DecCBOR (TxDatsRaw era) where
decCBOR =
ifDecoderVersionAtLeast
(natVersion @9)
( allowTag setTag
>> TxDatsRaw . Map.fromElems hashData . NE.toList <$> decodeNonEmptyList decCBOR
)
(TxDatsRaw . Map.fromElems hashData <$> decodeList decCBOR)
{-# INLINE decCBOR #-}

-- | Note that 'TxDats' are based on 'MemoBytes' since we must preserve
-- the original bytes for the 'Cardano.Ledger.Alonzo.Tx.ScriptIntegrity'.
-- Since the 'TxDats' exist outside of the transaction body,
-- this is how we ensure that they are not manipulated.
newtype TxDats era = TxDatsConstr (MemoBytes (TxDatsRaw era))
deriving newtype (SafeToHash, ToCBOR, Eq, NoThunks, NFData)
deriving newtype (SafeToHash, ToCBOR, Eq, NoThunks, NFData, DecCBOR)
deriving (Generic)

instance Memoized (TxDats era) where
Expand Down

0 comments on commit 0a26a78

Please sign in to comment.