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.
Summary
The event scan loop Unmarshals on every row regardless of whether or not the
scannercallback 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.godb/event.go:428event scan loop: event.UnmarshalBinary(row.eventData) per row.row.eventDataasDiagnosticEventViewand run filter checks against view accessors (contract ID, type, topic patterns)event.UnmarshalBinarywhen filter passes AND the scanner callback genuinely needs the decoded formget_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 outputScanFunctionsignature 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.