Skip to content

Commit

Permalink
Merge pull request #4 from CardanoSolutions/neil/missing-hashes
Browse files Browse the repository at this point in the history
Neil/missing hashes
  • Loading branch information
KtorZ authored Jan 23, 2024
2 parents 668254b + 1104a4b commit 317ffa5
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 6 deletions.
11 changes: 6 additions & 5 deletions cardano-node/src/Cardano/Node/LedgerEvent.hs
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ import qualified Codec.CBOR.Decoding as CBOR
import qualified Codec.CBOR.Encoding as CBOR
import qualified Codec.CBOR.Read as CBOR
import qualified Codec.CBOR.Write as CBOR
import Control.Arrow ((&&&))
import Control.Arrow ((&&&), (***))
import Control.Concurrent.STM (newTChanIO, readTChan, writeTChan)
import Control.Monad.Fail (MonadFail (..))
import Control.State.Transition (Event)
Expand Down Expand Up @@ -159,7 +159,7 @@ instance Crypto crypto => DecCBOR (LedgerEvent crypto) where
SumD LedgerBody
decRaw n = Invalid n

type LedgerEvents = NE.NonEmpty (LedgerEvent StandardCrypto) -- ^ convenient alias to refer to a list of LedgerEvents
type LedgerEvents = [LedgerEvent StandardCrypto] -- ^ convenient alias to refer to a list of LedgerEvents

-- TODO(KtorZ): Discuss that design choice; I believe we should favor a more
-- 'flat' structure for events instead of preserving whatever the ledger imposes
Expand Down Expand Up @@ -711,7 +711,7 @@ data AnchoredEvents =
, blockHeaderHash :: !ShortByteString
, slotNo :: !SlotNo
, blockNo :: !BlockNo
, ledgerEvents :: !(NonEmpty (LedgerEvent StandardCrypto))
, ledgerEvents :: ![LedgerEvent StandardCrypto]
}
deriving (Eq, Show)

Expand Down Expand Up @@ -850,5 +850,6 @@ mkVersionedAnchoredEvents prevHash headerHash slotNo blockNo auxEvents =
chainHashToOriginHash :: ChainHash b -> WithOrigin (HeaderHash b)
chainHashToOriginHash GenesisHash = Origin
chainHashToOriginHash (BlockHash bh) = At bh
versionedEvents = mapMaybe (sequence . (eventCodecVersion &&& fromAuxLedgerEvent)) auxEvents
versionedGroups = map (first NE.head . NE.unzip) . NE.groupBy ((==) `on` fst) $ versionedEvents
versionedEvents = map (eventCodecVersion &&& fromAuxLedgerEvent) auxEvents
versionedGroups = map makeGroup $ NE.groupWith fst versionedEvents
makeGroup = (NE.head *** catMaybes . NE.toList) . NE.unzip
2 changes: 1 addition & 1 deletion cardano-node/test/Test/Cardano/Node/LedgerEvent.hs
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ genAnchoredEvents =
<*> genBlockHeaderHash
<*> genSlotNo
<*> genBlockNo
<*> Gen.nonEmpty
<*> Gen.list
(Range.linear 0 20)
(Gen.choice
(mconcat
Expand Down

0 comments on commit 317ffa5

Please sign in to comment.