Skip to content

Conversation

@agaffney
Copy link
Contributor

@agaffney agaffney commented Nov 19, 2025

Fixes #409

Summary by CodeRabbit

  • Refactor
    • Optimized internal data decoding process with no changes to user-facing functionality.

@agaffney agaffney requested a review from a team as a code owner November 19, 2025 00:28
@coderabbitai
Copy link

coderabbitai bot commented Nov 19, 2025

📝 Walkthrough

Walkthrough

The change modifies the DNSReferenceRefScriptDatum.UnmarshalCBOR method in internal/indexer/datum.go to replace the cbor.DecodeGeneric function call with an explicit decode path. The new approach decodes the inner constructor into a temporary typed alias, then assigns the result back to the original type. The previously included explanatory comment about DecodeGeneric is removed, along with the generic decoding logic.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

  • Single file and method affected, making this a localized change
  • Straightforward refactoring from generic to explicit decoding approach
  • Consistency of the typed alias pattern and correctness of the explicit decode path should be verified
  • Ensure the new approach handles all edge cases previously covered by DecodeGeneric

Pre-merge checks and finishing touches

✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title 'refactor: remove use of cbor.DecodeGeneric' clearly describes the main change in the PR: replacing cbor.DecodeGeneric with an explicit decode path.
Linked Issues check ✅ Passed The PR successfully addresses the objective in issue #409 by replacing cbor.DecodeGeneric with a direct decoding method that avoids reflection in DNSReferenceRefScriptDatum.UnmarshalCBOR.
Out of Scope Changes check ✅ Passed All changes are focused on the stated objective of removing cbor.DecodeGeneric usage from the DNSReferenceRefScriptDatum type; no out-of-scope modifications detected.
✨ Finishing touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch refactor/remove-cbor-decode-generic

📜 Recent review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between d584c7b and 17b8885.

📒 Files selected for processing (1)
  • internal/indexer/datum.go (1 hunks)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (1)
  • GitHub Check: Analyze (go)
🔇 Additional comments (1)
internal/indexer/datum.go (1)

58-65: Based on the script output and web search results, I can now verify the review comment. Let me generate the final rewritten version:

Verify the type alias pattern correctly handles the embedded cbor.StructAsArray directive by running existing tests.

The type alias approach is a correct and well-established Go pattern for avoiding infinite recursion when implementing custom unmarshalers. When a CBOR value implements the Unmarshaler interface, Unmarshal calls that value's UnmarshalCBOR method. By creating a type alias without the custom method, the decoder uses the default struct decoding logic, which should properly handle the embedded directive and improve performance by avoiding reflection-based decoding.

However, since no dedicated test functions were found for DNSReferenceRefScriptDatum, please verify this change against any integration tests that decode actual on-chain CBOR data to ensure the three byte slice fields (TldName, SymbolDrat, SymbolHns) are populated correctly and that the results match the previous DecodeGeneric approach.

Tip

📝 Customizable high-level summaries are now available in beta!

You can now customize how CodeRabbit generates the high-level summary in your pull requests — including its content, structure, tone, and formatting.

  • Provide your own instructions using the high_level_summary_instructions setting.
  • Format the summary however you like (bullet lists, tables, multi-section layouts, contributor stats, etc.).
  • Use high_level_summary_in_walkthrough to move the summary from the description to the walkthrough section.

Example instruction:

"Divide the high-level summary into five sections:

  1. 📝 Description — Summarize the main change in 50–60 words, explaining what was done.
  2. 📓 References — List relevant issues, discussions, documentation, or related PRs.
  3. 📦 Dependencies & Requirements — Mention any new/updated dependencies, environment variable changes, or configuration updates.
  4. 📊 Contributor Summary — Include a Markdown table showing contributions:
    | Contributor | Lines Added | Lines Removed | Files Changed |
  5. ✔️ Additional Notes — Add any extra reviewer context.
    Keep each section concise (under 200 words) and use bullet or numbered lists for clarity."

Note: This feature is currently in beta for Pro-tier users, and pricing will be announced later.


Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@agaffney agaffney merged commit 764f347 into main Nov 19, 2025
11 checks passed
@agaffney agaffney deleted the refactor/remove-cbor-decode-generic branch November 19, 2025 01:55
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.

Replace use of cbor.DecodeGeneric

3 participants