Skip to content

Remove GetCBOR wrapper from QueryLedgerPeerSnapshot#1160

Merged
Jimbo4350 merged 1 commit into
masterfrom
jordan/remove-getcbor-ledger-peer-snapshot
Mar 27, 2026
Merged

Remove GetCBOR wrapper from QueryLedgerPeerSnapshot#1160
Jimbo4350 merged 1 commit into
masterfrom
jordan/remove-getcbor-ledger-peer-snapshot

Conversation

@Jimbo4350
Copy link
Copy Markdown
Contributor

Changelog

- description: |
    Remove GetCBOR wrapper from QueryLedgerPeerSnapshot query. Return
    LedgerPeerSnapshot directly instead of Serialised LedgerPeerSnapshot.
# uncomment types applicable to the change:
  type:
   - breaking       # the API has changed in a breaking way
  # - compatible     # the API has changed but is non-breaking
  # - optimisation   # measurable performance improvements
  # - refactoring    # QoL changes
  # - bugfix         # fixes a defect
  # - test           # fixes/modifies tests
  # - maintenance    # not directly related to the code
  # - release        # related to a new release preparation
  # - documentation  # change in code docs, haddocks...
# uncomment at least one main project this PR is associated with
  projects:
   - cardano-api
  # - cardano-api-gen
  # - cardano-rpc
  # - cardano-wasm

Context

There is no reason to keep the LedgerPeerSnapshot result serialized — callers always need the deserialized value. This removes the GetCBOR wrapper so the query returns LedgerPeerSnapshot directly instead of Serialised LedgerPeerSnapshot.

Replaces #930.

How to trust this PR

2-file, 5-line change. The GetCBOR wrapper is removed from:

  • The QueryLedgerPeerSnapshot result type
  • The consensus query construction in toConsensusQueryShelleyBased
  • The result pattern matches in fromConsensusQueryResultShelleyBased
  • The queryLedgerPeerSnapshot type signature in Expr.hs

Builds cleanly (lib + gen + both test suites).

Checklist

  • Commit sequence broadly makes sense and commits have useful messages
  • New tests are added if needed and existing tests are updated
  • Self-reviewed the diff

Return LedgerPeerSnapshot directly instead of Serialised LedgerPeerSnapshot,
as there is no reason to keep the result serialized.
Copilot AI review requested due to automatic review settings March 26, 2026 19:49
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Removes the GetCBOR wrapper from the QueryLedgerPeerSnapshot query so callers receive a LedgerPeerSnapshot directly (instead of a Serialised LedgerPeerSnapshot), reflecting the fact that consumers always need the deserialized value.

Changes:

  • Adjust QueryLedgerPeerSnapshot result type to return LedgerPeerSnapshot directly.
  • Update consensus query construction to remove Consensus.GetCBOR.
  • Update query result pattern matches and the queryLedgerPeerSnapshot type signature accordingly.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.

File Description
cardano-api/src/Cardano/Api/Query/Internal/Type/QueryInMode.hs Removes GetCBOR from the query type/result mapping and consensus-query construction/result handling.
cardano-api/src/Cardano/Api/Query/Internal/Expr.hs Updates the public query helper’s type signature to return LedgerPeerSnapshot directly.

Copy link
Copy Markdown
Contributor

@palas palas 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. One thought: I am not sure of how users use this, but it may make sense to do one of two things:

  • Either deprecating/removing decodeLedgerPeerSnapshot
  • Or adding an encodeLedgerPeerSnapshot function

@Jimbo4350 Jimbo4350 added this pull request to the merge queue Mar 27, 2026
Merged via the queue into master with commit 5592300 Mar 27, 2026
37 checks passed
@Jimbo4350 Jimbo4350 deleted the jordan/remove-getcbor-ledger-peer-snapshot branch March 27, 2026 11:58
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.

3 participants