Skip to content

Commit

Permalink
Process PR comments
Browse files Browse the repository at this point in the history
  • Loading branch information
jorisdral authored and jasagredo committed Dec 2, 2022
1 parent f75227a commit 92b72cb
Show file tree
Hide file tree
Showing 6 changed files with 18 additions and 22 deletions.
8 changes: 4 additions & 4 deletions anti-diff/src/Data/Map/Diff/Strict.hs
Expand Up @@ -365,15 +365,15 @@ applyDiff (Values values) (Diff diffs) = Values $
newKeys _k h = case last h of
Insert x -> Just x
Delete _x -> Nothing
UnsafeAntiInsert _x -> error "impossible b"
UnsafeAntiDelete _x -> error "impossible c"
UnsafeAntiInsert _x -> error "Can not apply UnsafeAntiInsert diff"
UnsafeAntiDelete _x -> error "Can not apply UnsafeAntiDelete diff"

oldKeys :: k -> v -> NEDiffHistory v -> Maybe v
oldKeys _k _v1 h = case last h of
Insert x -> Just x
Delete _x -> Nothing
UnsafeAntiInsert _x -> error "impossible e"
UnsafeAntiDelete _x -> error "impossible f"
UnsafeAntiInsert _x -> error "Can not apply UnsafeAntiInsert diff"
UnsafeAntiDelete _x -> error "Can not apply UnsafeAntiDelete diff"

-- | Applies a diff to values for a specific set of keys.
--
Expand Down
Expand Up @@ -204,7 +204,7 @@ instance ShelleyBasedHardForkConstraints proto1 era1 proto2 era2
. Flip
, translateLedgerTablesWith =
\ShelleyLedgerTables { shelleyUTxOTable = diffMK } -> ShelleyLedgerTables {
shelleyUTxOTable = rawTranslateDiff
shelleyUTxOTable = fmap
( unTxOutWrapper
. SL.translateEra' (shelleyLedgerTranslationContext (unwrapLedgerConfig cfg2))
. TxOutWrapper
Expand Down
Expand Up @@ -910,7 +910,7 @@ translateLedgerStateShelleyToAllegraWrapper =

, translateLedgerTablesWith =
\ShelleyLedgerTables { shelleyUTxOTable = diffMK } ->
ShelleyLedgerTables { shelleyUTxOTable = rawTranslateDiff (SL.translateEra' ()) diffMK
ShelleyLedgerTables { shelleyUTxOTable = fmap (SL.translateEra' ()) diffMK
}
}

Expand Down Expand Up @@ -953,7 +953,7 @@ translateLedgerStateAllegraToMaryWrapper =
. Flip
, translateLedgerTablesWith =
\ShelleyLedgerTables { shelleyUTxOTable = diffMK } ->
ShelleyLedgerTables { shelleyUTxOTable = rawTranslateDiff (SL.translateEra' ()) diffMK
ShelleyLedgerTables { shelleyUTxOTable = fmap (SL.translateEra' ()) diffMK
}
}

Expand Down Expand Up @@ -1000,7 +1000,7 @@ translateLedgerStateMaryToAlonzoWrapper =
. Flip
, translateLedgerTablesWith =
\ShelleyLedgerTables { shelleyUTxOTable = diffMK } ->
ShelleyLedgerTables { shelleyUTxOTable = rawTranslateDiff Alonzo.translateTxOut diffMK
ShelleyLedgerTables { shelleyUTxOTable = fmap Alonzo.translateTxOut diffMK
}
}

Expand Down Expand Up @@ -1053,7 +1053,7 @@ translateLedgerStateAlonzoToBabbageWrapper =
. transPraosLS
, translateLedgerTablesWith =
\ShelleyLedgerTables { shelleyUTxOTable = diffMK } ->
ShelleyLedgerTables { shelleyUTxOTable = rawTranslateDiff Babbage.translateTxOut diffMK
ShelleyLedgerTables { shelleyUTxOTable = fmap Babbage.translateTxOut diffMK
}
}
where
Expand Down
10 changes: 3 additions & 7 deletions ouroboros-consensus/src/Ouroboros/Consensus/Ledger/Basics.hs
Expand Up @@ -102,7 +102,6 @@ module Ouroboros.Consensus.Ledger.Basics (
, prependLedgerTablesDiffsRaw
, prependLedgerTablesDiffsTicked
, prependLedgerTablesTrackingDiffs
, rawTranslateDiff
, reapplyTrackingTicked
-- ** Special classes of ledger states
, InMemory (..)
Expand Down Expand Up @@ -744,12 +743,6 @@ reapplyTrackingTicked after before =
zipOverLedgerTablesTicked rawReapplyTracking after
$ projectLedgerTables before

rawTranslateDiff ::
(v -> v')
-> DiffMK k v
-> DiffMK k v'
rawTranslateDiff f (ApplyDiffMK d) = ApplyDiffMK $ fmap f d

{-------------------------------------------------------------------------------
Concrete ledger tables
-------------------------------------------------------------------------------}
Expand Down Expand Up @@ -813,6 +806,9 @@ instance Ord k => Semigroup (ApplyMapKind' KeysMK' k v) where
instance Ord k => Monoid (ApplyMapKind' KeysMK' k v) where
mempty = ApplyKeysMK mempty

instance Functor (DiffMK k) where
fmap f (ApplyDiffMK d) = ApplyDiffMK $ fmap f d

mapValuesAppliedMK :: (Ord k, Eq v, Eq v') => (v -> v') -> ApplyMapKind' mk k v -> ApplyMapKind' mk k v'
mapValuesAppliedMK f = \case
ApplyEmptyMK -> ApplyEmptyMK
Expand Down
Expand Up @@ -155,14 +155,14 @@ data RootMeasure k v = RootMeasure {
data InternalMeasure k v = InternalMeasure {
-- | Cumulative length
imLength :: {-# UNPACK #-} !Length
-- | Left-most slot number (or lower bound)
-- | Leftmost slot number (or lower bound)
--
-- Empty diff sequences have no right-most slot number, so in that case
-- Empty diff sequences have no rightmost slot number, so in that case
-- @imSlotNo == Nothing@.
, imSlotNoL :: !(Maybe SlotNoLB)
-- | Right-most slot number (or upper bound)
-- | Rightmost slot number (or upper bound)
--
-- Empty diff sequences have no left-most slot number, so in that case
-- Empty diff sequences have no leftmost slot number, so in that case
-- @imSlotNo == Nothing@.
, imSlotNoR :: !(Maybe SlotNoUB)
}
Expand Down
Expand Up @@ -679,8 +679,8 @@ mkDiskLedgerView (LedgerBackingStoreValueHandle seqNo vh, ldb, close) =
oneIfDel x = case x of
DS.Delete _ -> 1
DS.Insert _ -> 0
DS.UnsafeAntiDelete _ -> error "Found UnsafeAntiDelete"
DS.UnsafeAntiInsert _ -> error "Found UnsafeAntiInsert"
DS.UnsafeAntiDelete _ -> 0
DS.UnsafeAntiInsert _ -> 0


-- INVARIANT: nrequested > 0
Expand Down

0 comments on commit 92b72cb

Please sign in to comment.