Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improve TxSeq decoders #4904

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open

Improve TxSeq decoders #4904

wants to merge 3 commits into from

Conversation

teodanciu
Copy link
Contributor

Description

Changes the decoders of the TxAuxData within TxSeq to deserialize as IntMap instead of Map Int

Closes #4900

Checklist

  • Commits in meaningful sequence and with useful messages
  • Tests added or updated when needed
  • CHANGELOG.md files updated for packages with externally visible changes

    New section is never added with the code changes. (See RELEASING.md)
  • Versions updated in .cabal and CHANGELOG.md files when necessary, according to the
    versioning process.
  • Version bounds in .cabal files updated when necessary

    If you change the bounds in a cabal file, that package itself must have a version increase. (See RELEASING.md)
  • Code formatted (use scripts/fourmolize.sh)
  • Cabal files formatted (use scripts/cabal-format.sh)
  • hie.yaml updated (use scripts/gen-hie.sh)
  • Self-reviewed the diff

@teodanciu teodanciu requested a review from a team as a code owner February 21, 2025 14:03
@teodanciu teodanciu marked this pull request as draft February 21, 2025 14:03
@teodanciu teodanciu removed the request for review from a team February 21, 2025 14:04
@teodanciu teodanciu marked this pull request as ready for review February 21, 2025 16:02
@teodanciu teodanciu force-pushed the td/improve-txseq-decoders branch from 68bc780 to e5934d3 Compare February 21, 2025 16:52
Copy link
Collaborator

@lehins lehins left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good. Just one suggestion with simplification.
Thank you

@@ -242,6 +226,21 @@ txSeqDecoder lax = do
Seq.zipWith3 segWitAnnTx bodies wits metadata
pure $ TxSeq' <$> txns <*> bodiesAnn <*> witsAnn <*> metadataAnn

auxDataSeqDecoder ::
Int -> IntMap (m (TxAuxData era)) -> Bool -> Decoder s (Seq (Maybe (m (TxAuxData era))))
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This will allow you to avoid using runIdentity

Suggested change
Int -> IntMap (m (TxAuxData era)) -> Bool -> Decoder s (Seq (Maybe (m (TxAuxData era))))
Int -> IntMap a -> Bool -> Decoder s (Seq (Maybe a))

Comment on lines +244 to +245
fmap (fmap runIdentity)
<$> auxDataSeqDecoder bodiesLength (fmap pure auxDataMap) False
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There is no need to complicate the normal decoder

Suggested change
fmap (fmap runIdentity)
<$> auxDataSeqDecoder bodiesLength (fmap pure auxDataMap) False
auxDataSeqDecoder bodiesLength auxDataMap False

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Switch to using IntMap for TxSeq decoding
2 participants