Skip to content
This repository has been archived by the owner on Jan 13, 2025. It is now read-only.

RPC: use finalized as default pubsub commitment level #16659

Merged
merged 3 commits into from
Apr 20, 2021
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 4 additions & 9 deletions core/src/rpc_subscriptions.rs
Original file line number Diff line number Diff line change
Expand Up @@ -630,9 +630,7 @@ impl RpcSubscriptions {
subscriber: Subscriber<Response<UiAccount>>,
) {
let config = config.unwrap_or_default();
let commitment = config
.commitment
.unwrap_or_else(CommitmentConfig::confirmed);
let commitment = config.commitment.unwrap_or_default();

let slot = if commitment.is_finalized() {
self.block_commitment_cache
Expand Down Expand Up @@ -703,10 +701,7 @@ impl RpcSubscriptions {
subscriber: Subscriber<Response<RpcKeyedAccount>>,
) {
let config = config.unwrap_or_default();
let commitment = config
.account_config
.commitment
.unwrap_or_else(CommitmentConfig::confirmed);
let commitment = config.account_config.commitment.unwrap_or_default();

let mut subscriptions = if commitment.is_confirmed() {
self.subscriptions
Expand Down Expand Up @@ -753,7 +748,7 @@ impl RpcSubscriptions {
sub_id: SubscriptionId,
subscriber: Subscriber<Response<RpcLogsResponse>>,
) {
let commitment = commitment.unwrap_or_else(CommitmentConfig::confirmed);
let commitment = commitment.unwrap_or_default();

{
let mut subscriptions = if commitment.is_confirmed() {
Expand Down Expand Up @@ -864,7 +859,7 @@ impl RpcSubscriptions {
.map(|config| (config.commitment, config.enable_received_notification))
.unwrap_or_default();

let commitment = commitment.unwrap_or_else(CommitmentConfig::confirmed);
let commitment = commitment.unwrap_or_default();

let mut subscriptions = if commitment.is_confirmed() {
self.subscriptions
Expand Down
2 changes: 1 addition & 1 deletion docs/src/developing/clients/jsonrpc-api.md
Original file line number Diff line number Diff line change
Expand Up @@ -3050,7 +3050,7 @@ After connecting to the RPC PubSub websocket at `ws://<ADDRESS>/`:

- Submit subscription requests to the websocket using the methods below
- Multiple subscriptions may be active at once
- Many subscriptions take the optional [`commitment` parameter](jsonrpc-api.md#configuring-state-commitment), defining how finalized a change should be to trigger a notification. For subscriptions, if commitment is unspecified, the default value is `"confirmed"`.
- Many subscriptions take the optional [`commitment` parameter](jsonrpc-api.md#configuring-state-commitment), defining how finalized a change should be to trigger a notification. For subscriptions, if commitment is unspecified, the default value is `"finalized"`.

### accountSubscribe

Expand Down