Skip to content

PSwap: Collapse NoteObserver into the existing OnNoteReceived abstraction #2279

Description

@VAIBHAVJINDAL3012

Context

Follow-up from PR #2231 review (thread). Quoting @igamigo's approval review:

I'd want to remove the note observer trait and collapse it into the existing OnNoteReceived. The setup feels a bit more complex than it needs to be right now. The alternative could be to remove the traits and hardcode the logic, and try to do a separate PR for making it more generic (e.g., as part of #2209). This way we also reduce the diff.

Problem

The PSWAP tracking work introduced a new NoteObserver trait (crates/rust-client/src/sync/note_observer.rs:16) alongside the pre-existing OnNoteReceived screening callback. They overlap: OnNoteReceived filters notes, while NoteObserver collects filtered notes and applies follow-up logic. This is one abstraction more than necessary.

Proposed work

  • Fold NoteObserver's responsibilities into OnNoteReceived (or a minimal extension of it), removing the standalone trait.
  • Re-express PswapChainObserver on top of the unified abstraction.
  • Alternatively, if a clean unification isn't possible now, hardcode the PSWAP logic and pursue the generic version separately under Feature to subscribe based on attachment and tag, instead of just tag. #2209 — whichever reduces surface area.

Acceptance criteria

  • NoteObserver trait removed; PSWAP discovery runs through OnNoteReceived.
  • No behavioral change to PSWAP lineage tracking (existing pswap_* tests stay green).

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions