Skip to content

Conversation

@boqishan
Copy link

@boqishan boqishan commented Dec 19, 2025

Updated the comments for the GetAddressNotifications function to accurately reflect its behavior of monitoring address notifications via WebSocket events for new transactions and returning related UTXOs, correcting the previous misleading description.

Summary by CodeRabbit

  • Refactor
    • Switched UTXO notification to address-centric real-time monitoring via WebSocket events instead of group-based tracking.
    • Added automatic reconnection and context-aware cancellation for more resilient streams.
    • Introduced buffered notification delivery to avoid blocking during concurrent updates and improve reliability of UTXO notifications.

✏️ Tip: You can customize this high-level summary in your review settings.

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Dec 19, 2025

Walkthrough

Replaced group-based notifications with an address-centric notifier: added GetAddressNotifications(ctx) which ensures a group exists, opens a WebSocket to listen for newtransaction events, queries UTXOs for reported tx hashes, and emits UTXO slices on a buffered channel with reconnection and context-cancellation handling. (≤50 words)

Changes

Cohort / File(s) Summary
NBXplorer Service Notification
pkg/arkd-wallet/core/infrastructure/nbxplorer/service.go
Removed GetGroupNotifications; added GetAddressNotifications(ctx) (<-chan []ports.Utxo, error). New implementation: ensures group exists (creates empty if needed), opens WebSocket, listens for newtransaction events, extracts tx hash, queries for related UTXOs, sends results on a buffered channel, handles read errors with reconnects and respects context cancellation.

Sequence Diagram(s)

sequenceDiagram
    participant Caller
    participant Service as NBXplorer Service
    participant WS as WebSocket
    participant Query as UTXO Query
    participant Channel as Notification Channel

    Caller->>Service: GetAddressNotifications(ctx)
    activate Service
    Service->>Service: Ensure/create group
    Service->>WS: Open WebSocket connection
    activate WS
    WS-->>Service: Connected

    loop Listen for events
        WS-->>Service: newtransaction event
        Service->>Service: Parse tx hash
        Service->>Query: searchNewUTXOs(txHash)
        activate Query
        Query-->>Service: []ports.Utxo
        deactivate Query
        Service->>Channel: send []ports.Utxo (buffered)
    end

    alt Read error or disconnect
        Service->>WS: reconnect loop until context done
    end

    Service-->>Caller: returns <-chan []ports.Utxo
    deactivate Service
Loading

Estimated code review effort

🎯 4 (Complex) | ⏱️ ~45 minutes

  • Review WebSocket connection lifecycle, reconnection/backoff behavior, and error handling
  • Verify correct parsing of newtransaction events and robust extraction of transaction hashes
  • Inspect searchNewUTXOs usage and UTXO-to-address association correctness
  • Confirm buffered channel sizing and non-blocking semantics
  • Validate context cancellation paths and resource cleanup

Suggested reviewers

  • altafan

Pre-merge checks and finishing touches

❌ Failed checks (1 warning)
Check name Status Explanation Resolution
Title check ⚠️ Warning The title describes fixing comments for GetAddressNotifications, but the raw_summary shows a complete method replacement with significant implementation changes, not just comment fixes. Update the title to accurately reflect the main change: replacing GetGroupNotifications with GetAddressNotifications method implementation, rather than portraying this as a minor comment fix.
✅ Passed checks (2 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
✨ Finishing touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment

📜 Recent review details

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 894cbe3 and 11b57b6.

📒 Files selected for processing (1)
  • pkg/arkd-wallet/core/infrastructure/nbxplorer/service.go (1 hunks)
🔇 Additional comments (1)
pkg/arkd-wallet/core/infrastructure/nbxplorer/service.go (1)

634-636: Comments accurately describe the function behavior.

The updated comments now correctly reflect that the function monitors address notifications via WebSocket events for new transactions and returns related UTXOs. This matches the implementation and addresses the previously misleading description.

Minor note: Line 634 appears to have a trailing space before the line break, which is a cosmetic issue.


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.

Copy link
Collaborator

@altafan altafan left a comment

Choose a reason for hiding this comment

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

@boqishan thank you for the contrib! The comment was quite outdated, nice catch :).

I left a suggestion for a better description of what's going on under the hood with this function.

@boqishan
Copy link
Author

@boqishan thank you for the contrib! The comment was quite outdated, nice catch :).

I left a suggestion for a better description of what's going on under the hood with this function.

@altafan Modified. Please review it again.

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.

2 participants