diff --git a/core/src/rpc_subscriptions.rs b/core/src/rpc_subscriptions.rs index 996f63fdb6..b5d1443042 100644 --- a/core/src/rpc_subscriptions.rs +++ b/core/src/rpc_subscriptions.rs @@ -643,9 +643,7 @@ impl RpcSubscriptions { subscriber: Subscriber>, ) { 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 @@ -716,10 +714,7 @@ impl RpcSubscriptions { subscriber: Subscriber>, ) { 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 @@ -766,7 +761,7 @@ impl RpcSubscriptions { sub_id: SubscriptionId, subscriber: Subscriber>, ) { - let commitment = commitment.unwrap_or_else(CommitmentConfig::confirmed); + let commitment = commitment.unwrap_or_default(); { let mut subscriptions = if commitment.is_confirmed() { @@ -877,7 +872,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 diff --git a/core/tests/rpc.rs b/core/tests/rpc.rs index 5c8eaa849f..d864c81da3 100644 --- a/core/tests/rpc.rs +++ b/core/tests/rpc.rs @@ -10,6 +10,7 @@ use serde_json::{json, Value}; use solana_account_decoder::UiAccount; use solana_client::{ rpc_client::RpcClient, + rpc_config::{RpcAccountInfoConfig, RpcSignatureSubscribeConfig}, rpc_response::{Response, RpcSignatureResult, SlotUpdate}, }; use solana_core::{rpc_pubsub::gen_client::Client as PubsubClient, test_validator::TestValidator}; @@ -272,7 +273,13 @@ fn test_rpc_subscriptions() { let status_sender = status_sender.clone(); tokio_01::spawn( client - .signature_subscribe(sig.clone(), None) + .signature_subscribe( + sig.clone(), + Some(RpcSignatureSubscribeConfig { + commitment: Some(CommitmentConfig::confirmed()), + ..RpcSignatureSubscribeConfig::default() + }), + ) .and_then(move |sig_stream| { sig_stream.for_each(move |result| { status_sender.send((sig.clone(), result)).unwrap(); @@ -301,7 +308,13 @@ fn test_rpc_subscriptions() { let account_sender = account_sender.clone(); tokio_01::spawn( client - .account_subscribe(pubkey, None) + .account_subscribe( + pubkey, + Some(RpcAccountInfoConfig { + commitment: Some(CommitmentConfig::confirmed()), + ..RpcAccountInfoConfig::default() + }), + ) .and_then(move |account_stream| { account_stream.for_each(move |result| { account_sender.send(result).unwrap(); diff --git a/docs/src/developing/clients/jsonrpc-api.md b/docs/src/developing/clients/jsonrpc-api.md index b971175fbc..f3b344d54a 100644 --- a/docs/src/developing/clients/jsonrpc-api.md +++ b/docs/src/developing/clients/jsonrpc-api.md @@ -3147,7 +3147,7 @@ After connecting to the RPC PubSub websocket at `ws://
/`: - 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