Skip to content

Adopt XDR Views: View-based event filtering + response #950

Description

@cjonas9

Summary

The event scan loop Unmarshals on every row regardless of whether or not the scanner callback filters the events. This decoding work can be avoided.

Scope

Files: cmd/stellar-rpc/internal/db/event.go, cmd/stellar-rpc/internal/methods/get_events.go

  • db/event.go:428 event scan loop: event.UnmarshalBinary(row.eventData) per row.
    • We should wrap row.eventData as DiagnosticEventView and run filter checks against view accessors (contract ID, type, topic patterns)
    • Only call event.UnmarshalBinary when filter passes AND the scanner callback genuinely needs the decoded form
  • get_events.go:296: xdr.MarshalBase64(segment) for each topic in non-JSON response output + get_events.go:304: xdr.MarshalBase64(v0.Data) for event data in non-JSON response output
    • We should slice topic and data bytes from the source via view rather than re-encoding
  • Possibly change ScanFunction signature to accept view (or both).

Acceptance criteria

The decoding work done in getEvents query handling no longer decodes in filtering and no longer encodes its responses.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    Status
    To Do

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions