Skip to content

feat(ws): support dataSlice in ProgramSubscribe#434

Open
ozpool wants to merge 1 commit into
solana-foundation:mainfrom
ozpool:feat/ws-programsubscribe-dataslice
Open

feat(ws): support dataSlice in ProgramSubscribe#434
ozpool wants to merge 1 commit into
solana-foundation:mainfrom
ozpool:feat/ws-programsubscribe-dataslice

Conversation

@ozpool
Copy link
Copy Markdown

@ozpool ozpool commented May 14, 2026

Summary

Adds ProgramSubscribeOpts + ProgramSubscribeWithConfig to mirror the optional configuration object the programSubscribe RPC method accepts, including the missing dataSlice parameter.

dataSlice asks the validator to return only the requested {offset, length} slice of each notified account's data field. For programSubscribe that's especially important: every account owned by the program emits notifications, so trimming the payload to the relevant header bytes (discriminators, mint, owner, amount, etc.) avoids shipping full account data on every update.

What changed

  • New ProgramSubscribeOpts { Commitment, Encoding, Filters, DataSlice }.
  • New ProgramSubscribeWithConfig(programID, opts) carries the full opts object through to the request body.
  • The existing ProgramSubscribeWithOpts(programID, commitment, encoding, filters) is preserved by delegating to the new opts form, and ProgramSubscribe(programID, commitment) is unchanged.

Test plan

  • go build ./...
  • go test ./...
  • New programSubscribe_test.go asserts: defaults, dataSlice JSON shape {\"offset\":N,\"length\":N}, and the combined dataSlice + filters path

Add ProgramSubscribeOpts and ProgramSubscribeWithConfig to mirror the
optional configuration object the programSubscribe RPC method accepts,
including the missing dataSlice parameter. dataSlice asks the
validator to return only the requested slice of each notified
account's data field. For programSubscribe that's especially
important: every account owned by the program emits notifications, so
trimming the payload to the relevant header bytes (discriminators,
mint, owner, amount, etc.) avoids shipping the full account data on
every update.

The existing ProgramSubscribeWithOpts(programID, commitment, encoding,
filters) entry point delegates to the new opts form, so existing
callers are not affected.

Adds wire-shape tests covering: defaults, dataSlice JSON shape
({"offset": N, "length": N}), and dataSlice combined with filters.
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.

1 participant