diff --git a/Cargo.lock b/Cargo.lock index 21498b61b3..504bfcfadf 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -4884,6 +4884,7 @@ dependencies = [ "solana-logger 1.12.0", "solana-program-runtime", "solana-remote-wallet", + "solana-rpc-client", "solana-sdk 1.12.0", "solana-streamer", "solana-test-validator", @@ -4942,58 +4943,15 @@ dependencies = [ name = "solana-client" version = "1.12.0" dependencies = [ - "anyhow", - "assert_matches", - "async-mutex", - "async-trait", - "base64 0.13.0", - "bincode", - "bs58", - "bytes", - "clap 2.33.3", - "crossbeam-channel", - "enum_dispatch", - "futures 0.3.23", - "futures-util", - "indexmap", - "indicatif", - "itertools", - "jsonrpc-core", - "jsonrpc-http-server", - "lazy_static", "log", - "quinn", - "quinn-proto", - "quinn-udp", - "rand 0.7.3", - "rand_chacha 0.2.2", - "rayon", - "reqwest", - "rustls 0.20.6", - "semver 1.0.13", - "serde", - "serde_derive", - "serde_json", - "solana-account-decoder", - "solana-clap-utils", - "solana-faucet", - "solana-logger 1.12.0", "solana-measure", - "solana-metrics", - "solana-net-utils", - "solana-perf", + "solana-pubsub-client", + "solana-rpc-client", + "solana-rpc-client-api", + "solana-rpc-client-nonce-utils", "solana-sdk 1.12.0", - "solana-streamer", - "solana-transaction-status", - "solana-version", - "solana-vote-program", - "spl-token-2022", - "thiserror", - "tokio", - "tokio-stream", - "tokio-tungstenite", - "tungstenite", - "url 2.2.2", + "solana-thin-client", + "solana-tpu-client", ] [[package]] @@ -5911,6 +5869,29 @@ dependencies = [ "tokio", ] +[[package]] +name = "solana-pubsub-client" +version = "1.12.0" +dependencies = [ + "crossbeam-channel", + "futures-util", + "log", + "reqwest", + "semver 1.0.13", + "serde", + "serde_derive", + "serde_json", + "solana-account-decoder", + "solana-rpc-client-api", + "solana-sdk 1.12.0", + "thiserror", + "tokio", + "tokio-stream", + "tokio-tungstenite", + "tungstenite", + "url 2.2.2", +] + [[package]] name = "solana-rayon-threadlimit" version = "1.12.0" @@ -5992,6 +5973,72 @@ dependencies = [ "tokio-util 0.6.9", ] +[[package]] +name = "solana-rpc-client" +version = "1.12.0" +dependencies = [ + "assert_matches", + "async-trait", + "base64 0.13.0", + "bincode", + "bs58", + "crossbeam-channel", + "futures 0.3.23", + "indicatif", + "jsonrpc-core", + "jsonrpc-http-server", + "log", + "reqwest", + "semver 1.0.13", + "serde", + "serde_derive", + "serde_json", + "solana-account-decoder", + "solana-rpc-client-api", + "solana-sdk 1.12.0", + "solana-transaction-status", + "solana-version", + "solana-vote-program", + "tokio", +] + +[[package]] +name = "solana-rpc-client-api" +version = "1.12.0" +dependencies = [ + "base64 0.13.0", + "bs58", + "jsonrpc-core", + "reqwest", + "semver 1.0.13", + "serde", + "serde_derive", + "serde_json", + "solana-account-decoder", + "solana-sdk 1.12.0", + "solana-transaction-status", + "solana-version", + "spl-token-2022", + "thiserror", +] + +[[package]] +name = "solana-rpc-client-nonce-utils" +version = "1.12.0" +dependencies = [ + "anyhow", + "clap 2.33.3", + "futures 0.3.23", + "serde_json", + "solana-account-decoder", + "solana-clap-utils", + "solana-rpc-client", + "solana-rpc-client-api", + "solana-sdk 1.12.0", + "thiserror", + "tokio", +] + [[package]] name = "solana-rpc-test" version = "1.12.0" @@ -6389,6 +6436,20 @@ dependencies = [ "tokio", ] +[[package]] +name = "solana-thin-client" +version = "1.12.0" +dependencies = [ + "bincode", + "log", + "rayon", + "solana-logger 1.12.0", + "solana-rpc-client", + "solana-rpc-client-api", + "solana-sdk 1.12.0", + "solana-tpu-client", +] + [[package]] name = "solana-tokens" version = "1.12.0" @@ -6420,6 +6481,43 @@ dependencies = [ "thiserror", ] +[[package]] +name = "solana-tpu-client" +version = "1.12.0" +dependencies = [ + "async-mutex", + "async-trait", + "bincode", + "crossbeam-channel", + "enum_dispatch", + "futures 0.3.23", + "futures-util", + "indexmap", + "indicatif", + "itertools", + "lazy_static", + "log", + "quinn", + "quinn-proto", + "quinn-udp", + "rand 0.7.3", + "rand_chacha 0.2.2", + "rayon", + "rustls 0.20.6", + "solana-logger 1.12.0", + "solana-measure", + "solana-metrics", + "solana-net-utils", + "solana-perf", + "solana-pubsub-client", + "solana-rpc-client", + "solana-rpc-client-api", + "solana-sdk 1.12.0", + "solana-streamer", + "thiserror", + "tokio", +] + [[package]] name = "solana-transaction-dos" version = "1.12.0" diff --git a/Cargo.toml b/Cargo.toml index d54b9f1bec..4f9383c861 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -58,10 +58,14 @@ members = [ "programs/stake", "programs/vote", "programs/zk-token-proof", + "pubsub-client", "rayon-threadlimit", "rbpf-cli", "remote-wallet", "rpc", + "rpc-client", + "rpc-client-api", + "rpc-client-nonce-utils", "rpc-test", "runtime", "runtime/store-tool", @@ -78,7 +82,9 @@ members = [ "streamer", "sys-tuner", "test-validator", + "thin-client", "tokens", + "tpu-client", "transaction-dos", "transaction-status", "upload-perf", diff --git a/cli/Cargo.toml b/cli/Cargo.toml index 6fdfa258c4..726643aeb1 100644 --- a/cli/Cargo.toml +++ b/cli/Cargo.toml @@ -39,6 +39,7 @@ solana-faucet = { path = "../faucet", version = "=1.12.0" } solana-logger = { path = "../logger", version = "=1.12.0" } solana-program-runtime = { path = "../program-runtime", version = "=1.12.0" } solana-remote-wallet = { path = "../remote-wallet", version = "=1.12.0" } +solana-rpc-client = { path = "../rpc-client", version = "=1.12.0" } solana-sdk = { path = "../sdk", version = "=1.12.0" } solana-transaction-status = { path = "../transaction-status", version = "=1.12.0" } solana-version = { path = "../version", version = "=1.12.0" } diff --git a/cli/src/cli.rs b/cli/src/cli.rs index d202a2a69f..e3b5b2967f 100644 --- a/cli/src/cli.rs +++ b/cli/src/cli.rs @@ -1713,10 +1713,10 @@ mod tests { serde_json::{json, Value}, solana_client::{ blockhash_query, - mock_sender_for_cli::SIGNATURE, rpc_request::RpcRequest, rpc_response::{Response, RpcResponseContext}, }, + solana_rpc_client::mock_sender_for_cli::SIGNATURE, solana_sdk::{ pubkey::Pubkey, signature::{ diff --git a/client/Cargo.toml b/client/Cargo.toml index 97e5aba275..db84cad6f7 100644 --- a/client/Cargo.toml +++ b/client/Cargo.toml @@ -10,60 +10,17 @@ license = "Apache-2.0" edition = "2021" [dependencies] -async-mutex = "1.4.0" -async-trait = "0.1.57" -base64 = "0.13.0" -bincode = "1.3.3" -bs58 = "0.4.0" -bytes = "1.2.1" -clap = "2.33.0" -crossbeam-channel = "0.5" -enum_dispatch = "0.3.8" -futures = "0.3" -futures-util = "0.3.21" -indexmap = "1.9.1" -indicatif = "0.17.0" -itertools = "0.10.2" -jsonrpc-core = "18.0.0" -lazy_static = "1.4.0" log = "0.4.17" -quinn = "0.8.4" -quinn-proto = "0.8.4" -quinn-udp = "0.1.3" -rand = "0.7.0" -rand_chacha = "0.2.2" -rayon = "1.5.3" -reqwest = { version = "0.11.11", default-features = false, features = ["blocking", "brotli", "deflate", "gzip", "rustls-tls", "json"] } -rustls = { version = "0.20.6", features = ["dangerous_configuration"] } -semver = "1.0.13" -serde = "1.0.143" -serde_derive = "1.0.103" -serde_json = "1.0.83" -solana-account-decoder = { path = "../account-decoder", version = "=1.12.0" } -solana-clap-utils = { path = "../clap-utils", version = "=1.12.0" } -solana-faucet = { path = "../faucet", version = "=1.12.0" } solana-measure = { path = "../measure", version = "=1.12.0" } -solana-metrics = { path = "../metrics", version = "=1.12.0" } -solana-net-utils = { path = "../net-utils", version = "=1.12.0" } +solana-pubsub-client = { path = "../pubsub-client", version = "=1.12.0" } +solana-rpc-client = { path = "../rpc-client", version = "=1.12.0" } +solana-rpc-client-api = { path = "../rpc-client-api", version = "=1.12.0" } +solana-rpc-client-nonce-utils = { path = "../rpc-client-nonce-utils", version = "=1.12.0" } solana-sdk = { path = "../sdk", version = "=1.12.0" } -solana-streamer = { path = "../streamer", version = "=1.12.0" } -solana-transaction-status = { path = "../transaction-status", version = "=1.12.0" } -solana-version = { path = "../version", version = "=1.12.0" } -solana-vote-program = { path = "../programs/vote", version = "=1.12.0" } -spl-token-2022 = { version = "=0.4.3", features = ["no-entrypoint"] } -thiserror = "1.0" -tokio = { version = "1", features = ["full"] } -tokio-stream = "0.1.9" -tokio-tungstenite = { version = "0.17.2", features = ["rustls-tls-webpki-roots"] } -tungstenite = { version = "0.17.2", features = ["rustls-tls-webpki-roots"] } -url = "2.2.2" +solana-thin-client = { path = "../thin-client", version = "=1.12.0" } +solana-tpu-client = { path = "../tpu-client", version = "=1.12.0" } [dev-dependencies] -anyhow = "1.0.58" -assert_matches = "1.5.0" -jsonrpc-http-server = "18.0.0" -solana-logger = { path = "../logger", version = "=1.12.0" } -solana-perf = { path = "../perf", version = "=1.12.0" } [package.metadata.docs.rs] targets = ["x86_64-unknown-linux-gnu"] diff --git a/client/src/client_error.rs b/client/src/client_error.rs deleted file mode 100644 index 961859abe6..0000000000 --- a/client/src/client_error.rs +++ /dev/null @@ -1,212 +0,0 @@ -pub use reqwest; -use { - crate::{nonblocking::quic_client::QuicError, rpc_request, rpc_response}, - quinn::ConnectError, - solana_faucet::faucet::FaucetError, - solana_sdk::{ - signature::SignerError, transaction::TransactionError, transport::TransportError, - }, - std::io, - thiserror::Error, -}; // export `reqwest` for clients - -#[derive(Error, Debug)] -pub enum ClientErrorKind { - #[error(transparent)] - Io(#[from] io::Error), - #[error(transparent)] - Reqwest(#[from] reqwest::Error), - #[error(transparent)] - RpcError(#[from] rpc_request::RpcError), - #[error(transparent)] - SerdeJson(#[from] serde_json::error::Error), - #[error(transparent)] - SigningError(#[from] SignerError), - #[error(transparent)] - TransactionError(#[from] TransactionError), - #[error(transparent)] - FaucetError(#[from] FaucetError), - #[error("Custom: {0}")] - Custom(String), -} - -impl ClientErrorKind { - pub fn get_transaction_error(&self) -> Option { - match self { - Self::RpcError(rpc_request::RpcError::RpcResponseError { - data: - rpc_request::RpcResponseErrorData::SendTransactionPreflightFailure( - rpc_response::RpcSimulateTransactionResult { - err: Some(tx_err), .. - }, - ), - .. - }) => Some(tx_err.clone()), - Self::TransactionError(tx_err) => Some(tx_err.clone()), - _ => None, - } - } -} - -impl From for ClientErrorKind { - fn from(err: TransportError) -> Self { - match err { - TransportError::IoError(err) => Self::Io(err), - TransportError::TransactionError(err) => Self::TransactionError(err), - TransportError::Custom(err) => Self::Custom(err), - } - } -} - -impl From for TransportError { - fn from(client_error_kind: ClientErrorKind) -> Self { - match client_error_kind { - ClientErrorKind::Io(err) => Self::IoError(err), - ClientErrorKind::TransactionError(err) => Self::TransactionError(err), - ClientErrorKind::Reqwest(err) => Self::Custom(format!("{:?}", err)), - ClientErrorKind::RpcError(err) => Self::Custom(format!("{:?}", err)), - ClientErrorKind::SerdeJson(err) => Self::Custom(format!("{:?}", err)), - ClientErrorKind::SigningError(err) => Self::Custom(format!("{:?}", err)), - ClientErrorKind::FaucetError(err) => Self::Custom(format!("{:?}", err)), - ClientErrorKind::Custom(err) => Self::Custom(format!("{:?}", err)), - } - } -} - -impl From for ClientErrorKind { - fn from(quic_error: QuicError) -> Self { - Self::Custom(format!("{:?}", quic_error)) - } -} - -impl From for ClientErrorKind { - fn from(connect_error: ConnectError) -> Self { - Self::Custom(format!("{:?}", connect_error)) - } -} - -#[derive(Error, Debug)] -#[error("{kind}")] -pub struct ClientError { - pub request: Option, - - #[source] - pub kind: ClientErrorKind, -} - -impl ClientError { - pub fn new_with_request(kind: ClientErrorKind, request: rpc_request::RpcRequest) -> Self { - Self { - request: Some(request), - kind, - } - } - - pub fn into_with_request(self, request: rpc_request::RpcRequest) -> Self { - Self { - request: Some(request), - ..self - } - } - - pub fn request(&self) -> Option<&rpc_request::RpcRequest> { - self.request.as_ref() - } - - pub fn kind(&self) -> &ClientErrorKind { - &self.kind - } - - pub fn get_transaction_error(&self) -> Option { - self.kind.get_transaction_error() - } -} - -impl From for ClientError { - fn from(kind: ClientErrorKind) -> Self { - Self { - request: None, - kind, - } - } -} - -impl From for ClientError { - fn from(err: TransportError) -> Self { - Self { - request: None, - kind: err.into(), - } - } -} - -impl From for TransportError { - fn from(client_error: ClientError) -> Self { - client_error.kind.into() - } -} - -impl From for ClientError { - fn from(err: std::io::Error) -> Self { - Self { - request: None, - kind: err.into(), - } - } -} - -impl From for ClientError { - fn from(err: reqwest::Error) -> Self { - Self { - request: None, - kind: err.into(), - } - } -} - -impl From for ClientError { - fn from(err: rpc_request::RpcError) -> Self { - Self { - request: None, - kind: err.into(), - } - } -} - -impl From for ClientError { - fn from(err: serde_json::error::Error) -> Self { - Self { - request: None, - kind: err.into(), - } - } -} - -impl From for ClientError { - fn from(err: SignerError) -> Self { - Self { - request: None, - kind: err.into(), - } - } -} - -impl From for ClientError { - fn from(err: TransactionError) -> Self { - Self { - request: None, - kind: err.into(), - } - } -} - -impl From for ClientError { - fn from(err: FaucetError) -> Self { - Self { - request: None, - kind: err.into(), - } - } -} - -pub type Result = std::result::Result; diff --git a/client/src/lib.rs b/client/src/lib.rs index 2cef3aa966..0371e20c6a 100644 --- a/client/src/lib.rs +++ b/client/src/lib.rs @@ -1,38 +1,120 @@ #![allow(clippy::integer_arithmetic)] -#[macro_use] -extern crate serde_derive; -#[macro_use] -extern crate solana_metrics; - -pub mod blockhash_query; -pub mod client_error; -pub mod connection_cache; -pub(crate) mod http_sender; -pub(crate) mod mock_sender; -pub mod nonblocking; -pub mod nonce_utils; -pub mod pubsub_client; -pub mod quic_client; -pub mod rpc_cache; -pub mod rpc_client; -pub mod rpc_config; -pub mod rpc_custom_error; -pub mod rpc_deprecated_config; -pub mod rpc_filter; -pub mod rpc_request; -pub mod rpc_response; -pub mod rpc_sender; -pub mod spinner; -pub mod thin_client; -pub mod tpu_client; -pub mod tpu_connection; pub mod transaction_executor; -pub mod udp_client; -pub mod mock_sender_for_cli { - /// Magic `SIGNATURE` value used by `solana-cli` unit tests. - /// Please don't use this constant. - pub const SIGNATURE: &str = - "43yNSFC6fYTuPgTNFFhF4axw7AfWxB2BPdurme8yrsWEYwm8299xh8n6TAHjGymiSub1XtyxTNyd9GBfY2hxoBw8"; +pub use solana_rpc_client::mock_sender_for_cli; + +pub mod blockhash_query { + pub use solana_rpc_client_nonce_utils::blockhash_query::*; +} +pub mod client_error { + pub use solana_rpc_client_api::client_error::{ + reqwest, Error as ClientError, ErrorKind as ClientErrorKind, Result, + }; +} +pub mod connection_cache { + pub use solana_tpu_client::connection_cache::*; +} +pub mod nonblocking { + pub mod blockhash_query { + pub use solana_rpc_client_nonce_utils::nonblocking::blockhash_query::*; + } + /// Durable transaction nonce helpers. + pub mod nonce_utils { + pub use solana_rpc_client_nonce_utils::nonblocking::*; + } + pub mod pubsub_client { + pub use solana_pubsub_client::nonblocking::pubsub_client::*; + } + /// Simple nonblocking client that connects to a given UDP port with the QUIC protocol + /// and provides an interface for sending transactions which is restricted by the + /// server's flow control. + pub mod quic_client { + pub use solana_tpu_client::nonblocking::quic_client::*; + } + /// Communication with a Solana node over RPC asynchronously . + /// + /// Software that interacts with the Solana blockchain, whether querying its + /// state or submitting transactions, communicates with a Solana node over + /// [JSON-RPC], using the [`RpcClient`] type. + /// + /// [JSON-RPC]: https://www.jsonrpc.org/specification + pub mod rpc_client { + pub use solana_rpc_client::nonblocking::rpc_client::*; + } + pub mod tpu_client { + pub use solana_tpu_client::nonblocking::tpu_client::*; + } + /// Trait defining async send functions, to be used for UDP or QUIC sending + pub mod tpu_connection { + pub use solana_tpu_client::nonblocking::tpu_connection::*; + } + /// Simple UDP client that communicates with the given UDP port with UDP and provides + /// an interface for sending transactions + pub mod udp_client { + pub use solana_tpu_client::nonblocking::udp_client::*; + } +} +/// Durable transaction nonce helpers. +pub mod nonce_utils { + pub use solana_rpc_client_nonce_utils::*; +} +pub mod pubsub_client { + pub use solana_pubsub_client::pubsub_client::*; +} +/// Simple client that connects to a given UDP port with the QUIC protocol and provides +/// an interface for sending transactions which is restricted by the server's flow control. +pub mod quic_client { + pub use solana_tpu_client::quic_client::*; +} +/// Communication with a Solana node over RPC. +/// +/// Software that interacts with the Solana blockchain, whether querying its +/// state or submitting transactions, communicates with a Solana node over +/// [JSON-RPC], using the [`RpcClient`] type. +/// +/// [JSON-RPC]: https://www.jsonrpc.org/specification +pub mod rpc_client { + pub use solana_rpc_client::rpc_client::*; +} +pub mod rpc_config { + pub use solana_rpc_client_api::config::*; +} +/// Implementation defined RPC server errors +pub mod rpc_custom_error { + pub use solana_rpc_client_api::custom_error::*; +} +pub mod rpc_deprecated_config { + pub use solana_rpc_client_api::deprecated_config::*; +} +pub mod rpc_filter { + pub use solana_rpc_client_api::filter::*; +} +pub mod rpc_request { + pub use solana_rpc_client_api::request::*; +} +pub mod rpc_response { + pub use solana_rpc_client_api::response::*; +} +/// A transport for RPC calls. +pub mod rpc_sender { + pub use solana_rpc_client::rpc_sender::*; +} +/// The `thin_client` module is a client-side object that interfaces with +/// a server-side TPU. Client code should use this object instead of writing +/// messages to the network directly. The binary encoding of its messages are +/// unstable and may change in future releases. +pub mod thin_client { + pub use solana_thin_client::thin_client::*; +} +pub mod tpu_client { + pub use solana_tpu_client::tpu_client::*; +} +pub mod tpu_connection { + pub use solana_tpu_client::tpu_connection::*; +} +/// Simple TPU client that communicates with the given UDP port with UDP and provides +/// an interface for sending transactions +pub mod udp_client { + pub use solana_tpu_client::udp_client::*; } diff --git a/client/src/nonblocking/mod.rs b/client/src/nonblocking/mod.rs deleted file mode 100644 index 7ba96d3994..0000000000 --- a/client/src/nonblocking/mod.rs +++ /dev/null @@ -1,8 +0,0 @@ -pub mod blockhash_query; -pub mod nonce_utils; -pub mod pubsub_client; -pub mod quic_client; -pub mod rpc_client; -pub mod tpu_client; -pub mod tpu_connection; -pub mod udp_client; diff --git a/client/src/spinner.rs b/client/src/spinner.rs deleted file mode 100644 index 177ae3d789..0000000000 --- a/client/src/spinner.rs +++ /dev/null @@ -1,40 +0,0 @@ -//! Spinner creator - -use { - indicatif::{ProgressBar, ProgressStyle}, - std::time::Duration, -}; - -pub(crate) fn new_progress_bar() -> ProgressBar { - let progress_bar = ProgressBar::new(42); - progress_bar.set_style( - ProgressStyle::default_spinner() - .template("{spinner:.green} {wide_msg}") - .expect("ProgresStyle::template direct input to be correct"), - ); - progress_bar.enable_steady_tick(Duration::from_millis(100)); - progress_bar -} - -pub(crate) fn set_message_for_confirmed_transactions( - progress_bar: &ProgressBar, - confirmed_transactions: u32, - total_transactions: usize, - block_height: Option, - last_valid_block_height: u64, - status: &str, -) { - progress_bar.set_message(format!( - "{:>5.1}% | {:<40}{}", - confirmed_transactions as f64 * 100. / total_transactions as f64, - status, - match block_height { - Some(block_height) => format!( - " [block height {}; re-sign in {} blocks]", - block_height, - last_valid_block_height.saturating_sub(block_height), - ), - None => String::new(), - }, - )); -} diff --git a/client/src/transaction_executor.rs b/client/src/transaction_executor.rs index 89a70d7ee5..5c6e4674a4 100644 --- a/client/src/transaction_executor.rs +++ b/client/src/transaction_executor.rs @@ -1,8 +1,8 @@ #![allow(clippy::integer_arithmetic)] use { - crate::rpc_client::RpcClient, log::*, solana_measure::measure::Measure, + solana_rpc_client::rpc_client::RpcClient, solana_sdk::{ commitment_config::CommitmentConfig, signature::Signature, timing::timestamp, transaction::Transaction, diff --git a/programs/bpf/Cargo.lock b/programs/bpf/Cargo.lock index 78f7c69dfc..f1e6ae70f6 100644 --- a/programs/bpf/Cargo.lock +++ b/programs/bpf/Cargo.lock @@ -4649,53 +4649,15 @@ dependencies = [ name = "solana-client" version = "1.12.0" dependencies = [ - "async-mutex", - "async-trait", - "base64 0.13.0", - "bincode", - "bs58", - "bytes", - "clap 2.33.3", - "crossbeam-channel", - "enum_dispatch", - "futures 0.3.23", - "futures-util", - "indexmap", - "indicatif", - "itertools", - "jsonrpc-core", - "lazy_static", "log", - "quinn", - "quinn-proto", - "quinn-udp", - "rand 0.7.3", - "rand_chacha 0.2.2", - "rayon", - "reqwest", - "rustls 0.20.6", - "semver", - "serde", - "serde_derive", - "serde_json", - "solana-account-decoder", - "solana-clap-utils", - "solana-faucet", "solana-measure", - "solana-metrics", - "solana-net-utils", + "solana-pubsub-client", + "solana-rpc-client", + "solana-rpc-client-api", + "solana-rpc-client-nonce-utils", "solana-sdk 1.12.0", - "solana-streamer", - "solana-transaction-status", - "solana-version", - "solana-vote-program", - "spl-token-2022", - "thiserror", - "tokio", - "tokio-stream", - "tokio-tungstenite", - "tungstenite", - "url 2.2.2", + "solana-thin-client", + "solana-tpu-client", ] [[package]] @@ -5312,6 +5274,29 @@ dependencies = [ "tokio", ] +[[package]] +name = "solana-pubsub-client" +version = "1.12.0" +dependencies = [ + "crossbeam-channel", + "futures-util", + "log", + "reqwest", + "semver", + "serde", + "serde_derive", + "serde_json", + "solana-account-decoder", + "solana-rpc-client-api", + "solana-sdk 1.12.0", + "thiserror", + "tokio", + "tokio-stream", + "tokio-tungstenite", + "tungstenite", + "url 2.2.2", +] + [[package]] name = "solana-rayon-threadlimit" version = "1.12.0" @@ -5388,6 +5373,61 @@ dependencies = [ "tokio-util 0.6.9", ] +[[package]] +name = "solana-rpc-client" +version = "1.12.0" +dependencies = [ + "async-trait", + "base64 0.13.0", + "bincode", + "bs58", + "indicatif", + "log", + "reqwest", + "semver", + "serde", + "serde_derive", + "serde_json", + "solana-account-decoder", + "solana-rpc-client-api", + "solana-sdk 1.12.0", + "solana-transaction-status", + "solana-version", + "solana-vote-program", + "tokio", +] + +[[package]] +name = "solana-rpc-client-api" +version = "1.12.0" +dependencies = [ + "base64 0.13.0", + "bs58", + "jsonrpc-core", + "reqwest", + "semver", + "serde", + "serde_derive", + "serde_json", + "solana-account-decoder", + "solana-sdk 1.12.0", + "solana-transaction-status", + "solana-version", + "spl-token-2022", + "thiserror", +] + +[[package]] +name = "solana-rpc-client-nonce-utils" +version = "1.12.0" +dependencies = [ + "clap 2.33.3", + "solana-clap-utils", + "solana-rpc-client", + "solana-sdk 1.12.0", + "thiserror", +] + [[package]] name = "solana-runtime" version = "1.12.0" @@ -5719,6 +5759,51 @@ dependencies = [ "tokio", ] +[[package]] +name = "solana-thin-client" +version = "1.12.0" +dependencies = [ + "bincode", + "log", + "solana-rpc-client", + "solana-rpc-client-api", + "solana-sdk 1.12.0", + "solana-tpu-client", +] + +[[package]] +name = "solana-tpu-client" +version = "1.12.0" +dependencies = [ + "async-mutex", + "async-trait", + "bincode", + "enum_dispatch", + "futures 0.3.23", + "futures-util", + "indexmap", + "indicatif", + "itertools", + "lazy_static", + "log", + "quinn", + "quinn-proto", + "quinn-udp", + "rand 0.7.3", + "rayon", + "rustls 0.20.6", + "solana-measure", + "solana-metrics", + "solana-net-utils", + "solana-pubsub-client", + "solana-rpc-client", + "solana-rpc-client-api", + "solana-sdk 1.12.0", + "solana-streamer", + "thiserror", + "tokio", +] + [[package]] name = "solana-transaction-status" version = "1.12.0" diff --git a/pubsub-client/Cargo.toml b/pubsub-client/Cargo.toml new file mode 100644 index 0000000000..4056f711b4 --- /dev/null +++ b/pubsub-client/Cargo.toml @@ -0,0 +1,34 @@ +[package] +name = "solana-pubsub-client" +version = "1.12.0" +description = "Solana Pubsub Client" +authors = ["Solana Maintainers "] +repository = "https://github.com/solana-labs/solana" +license = "Apache-2.0" +homepage = "https://solana.com/" +documentation = "https://docs.rs/solana-pubsub-client" +edition = "2021" + +[dependencies] +crossbeam-channel = "0.5" +futures-util = "0.3.21" +log = "0.4.17" +reqwest = { version = "0.11.11", default-features = false, features = ["blocking", "brotli", "deflate", "gzip", "rustls-tls", "json"] } +semver = "1.0.13" +serde = "1.0.143" +serde_derive = "1.0.103" +serde_json = "1.0.83" +solana-account-decoder = { path = "../account-decoder", version = "=1.12.0" } +solana-rpc-client-api = { path = "../rpc-client-api", version = "=1.12.0" } +solana-sdk = { path = "../sdk", version = "=1.12.0" } +thiserror = "1.0" +tokio = { version = "1", features = ["full"] } +tokio-stream = "0.1.9" +tokio-tungstenite = { version = "0.17.2", features = ["rustls-tls-webpki-roots"] } +tungstenite = { version = "0.17.2", features = ["rustls-tls-webpki-roots"] } +url = "2.2.2" + +[dev-dependencies] + +[package.metadata.docs.rs] +targets = ["x86_64-unknown-linux-gnu"] diff --git a/pubsub-client/src/lib.rs b/pubsub-client/src/lib.rs new file mode 100644 index 0000000000..72beff330f --- /dev/null +++ b/pubsub-client/src/lib.rs @@ -0,0 +1,4 @@ +#![allow(clippy::integer_arithmetic)] + +pub mod nonblocking; +pub mod pubsub_client; diff --git a/pubsub-client/src/nonblocking/mod.rs b/pubsub-client/src/nonblocking/mod.rs new file mode 100644 index 0000000000..f598a89d8e --- /dev/null +++ b/pubsub-client/src/nonblocking/mod.rs @@ -0,0 +1 @@ +pub mod pubsub_client; diff --git a/client/src/nonblocking/pubsub_client.rs b/pubsub-client/src/nonblocking/pubsub_client.rs similarity index 99% rename from client/src/nonblocking/pubsub_client.rs rename to pubsub-client/src/nonblocking/pubsub_client.rs index 1aa6210d0f..79eb1cea90 100644 --- a/client/src/nonblocking/pubsub_client.rs +++ b/pubsub-client/src/nonblocking/pubsub_client.rs @@ -1,17 +1,4 @@ use { - crate::{ - http_sender::RpcErrorObject, - rpc_config::{ - RpcAccountInfoConfig, RpcBlockSubscribeConfig, RpcBlockSubscribeFilter, - RpcProgramAccountsConfig, RpcSignatureSubscribeConfig, RpcTransactionLogsConfig, - RpcTransactionLogsFilter, - }, - rpc_filter::maybe_map_filters, - rpc_response::{ - Response as RpcResponse, RpcBlockUpdate, RpcKeyedAccount, RpcLogsResponse, - RpcSignatureResult, RpcVersionInfo, RpcVote, SlotInfo, SlotUpdate, - }, - }, futures_util::{ future::{ready, BoxFuture, FutureExt}, sink::SinkExt, @@ -21,6 +8,19 @@ use { serde::de::DeserializeOwned, serde_json::{json, Map, Value}, solana_account_decoder::UiAccount, + solana_rpc_client_api::{ + config::{ + RpcAccountInfoConfig, RpcBlockSubscribeConfig, RpcBlockSubscribeFilter, + RpcProgramAccountsConfig, RpcSignatureSubscribeConfig, RpcTransactionLogsConfig, + RpcTransactionLogsFilter, + }, + error_object::RpcErrorObject, + filter::maybe_map_filters, + response::{ + Response as RpcResponse, RpcBlockUpdate, RpcKeyedAccount, RpcLogsResponse, + RpcSignatureResult, RpcVersionInfo, RpcVote, SlotInfo, SlotUpdate, + }, + }, solana_sdk::{clock::Slot, pubkey::Pubkey, signature::Signature}, std::collections::BTreeMap, thiserror::Error, diff --git a/client/src/pubsub_client.rs b/pubsub-client/src/pubsub_client.rs similarity index 99% rename from client/src/pubsub_client.rs rename to pubsub-client/src/pubsub_client.rs index 344082ed58..92e5f0d4af 100644 --- a/client/src/pubsub_client.rs +++ b/pubsub-client/src/pubsub_client.rs @@ -1,17 +1,5 @@ pub use crate::nonblocking::pubsub_client::PubsubClientError; use { - crate::{ - rpc_config::{ - RpcAccountInfoConfig, RpcBlockSubscribeConfig, RpcBlockSubscribeFilter, - RpcProgramAccountsConfig, RpcSignatureSubscribeConfig, RpcTransactionLogsConfig, - RpcTransactionLogsFilter, - }, - rpc_filter, - rpc_response::{ - Response as RpcResponse, RpcBlockUpdate, RpcKeyedAccount, RpcLogsResponse, - RpcSignatureResult, RpcVote, SlotInfo, SlotUpdate, - }, - }, crossbeam_channel::{unbounded, Receiver, Sender}, log::*, serde::de::DeserializeOwned, @@ -21,6 +9,18 @@ use { Map, Value, }, solana_account_decoder::UiAccount, + solana_rpc_client_api::{ + config::{ + RpcAccountInfoConfig, RpcBlockSubscribeConfig, RpcBlockSubscribeFilter, + RpcProgramAccountsConfig, RpcSignatureSubscribeConfig, RpcTransactionLogsConfig, + RpcTransactionLogsFilter, + }, + filter, + response::{ + Response as RpcResponse, RpcBlockUpdate, RpcKeyedAccount, RpcLogsResponse, + RpcSignatureResult, RpcVote, SlotInfo, SlotUpdate, + }, + }, solana_sdk::{clock::Slot, pubkey::Pubkey, signature::Signature}, std::{ marker::PhantomData, @@ -396,7 +396,7 @@ impl PubsubClient { let node_version = PubsubProgramClientSubscription::get_version(&socket_clone).ok(); // If node does not support the pubsub `getVersion` method, assume version is old // and filters should be mapped (node_version.is_none()). - rpc_filter::maybe_map_filters(node_version, filters) + filter::maybe_map_filters(node_version, filters) .map_err(PubsubClientError::RequestError)?; } } diff --git a/rpc-client-api/Cargo.toml b/rpc-client-api/Cargo.toml new file mode 100644 index 0000000000..250227410a --- /dev/null +++ b/rpc-client-api/Cargo.toml @@ -0,0 +1,31 @@ +[package] +name = "solana-rpc-client-api" +version = "1.12.0" +description = "Solana Client Common Utilities" +authors = ["Solana Maintainers "] +repository = "https://github.com/solana-labs/solana" +license = "Apache-2.0" +homepage = "https://solana.com/" +documentation = "https://docs.rs/solana-rpc-client-api" +edition = "2021" + +[dependencies] +base64 = "0.13.0" +bs58 = "0.4.0" +jsonrpc-core = "18.0.0" +reqwest = { version = "0.11.11", default-features = false, features = ["blocking", "brotli", "deflate", "gzip", "rustls-tls", "json"] } +semver = "1.0.13" +serde = "1.0.143" +serde_derive = "1.0.103" +serde_json = "1.0.83" +solana-account-decoder = { path = "../account-decoder", version = "=1.12.0" } +solana-sdk = { path = "../sdk", version = "=1.12.0" } +solana-transaction-status = { path = "../transaction-status", version = "=1.12.0" } +solana-version = { path = "../version", version = "=1.12.0" } +spl-token-2022 = { version = "=0.4.3", features = ["no-entrypoint"] } +thiserror = "1.0" + +[dev-dependencies] + +[package.metadata.docs.rs] +targets = ["x86_64-unknown-linux-gnu"] diff --git a/rpc-client-api/src/client_error.rs b/rpc-client-api/src/client_error.rs new file mode 100644 index 0000000000..4c17dea842 --- /dev/null +++ b/rpc-client-api/src/client_error.rs @@ -0,0 +1,186 @@ +pub use reqwest; +use { + crate::{request, response}, + solana_sdk::{ + signature::SignerError, transaction::TransactionError, transport::TransportError, + }, + std::io, + thiserror::Error as ThisError, +}; + +#[derive(ThisError, Debug)] +pub enum ErrorKind { + #[error(transparent)] + Io(#[from] io::Error), + #[error(transparent)] + Reqwest(#[from] reqwest::Error), + #[error(transparent)] + RpcError(#[from] request::RpcError), + #[error(transparent)] + SerdeJson(#[from] serde_json::error::Error), + #[error(transparent)] + SigningError(#[from] SignerError), + #[error(transparent)] + TransactionError(#[from] TransactionError), + #[error("Custom: {0}")] + Custom(String), +} + +impl ErrorKind { + pub fn get_transaction_error(&self) -> Option { + match self { + Self::RpcError(request::RpcError::RpcResponseError { + data: + request::RpcResponseErrorData::SendTransactionPreflightFailure( + response::RpcSimulateTransactionResult { + err: Some(tx_err), .. + }, + ), + .. + }) => Some(tx_err.clone()), + Self::TransactionError(tx_err) => Some(tx_err.clone()), + _ => None, + } + } +} + +impl From for ErrorKind { + fn from(err: TransportError) -> Self { + match err { + TransportError::IoError(err) => Self::Io(err), + TransportError::TransactionError(err) => Self::TransactionError(err), + TransportError::Custom(err) => Self::Custom(err), + } + } +} + +impl From for TransportError { + fn from(client_error_kind: ErrorKind) -> Self { + match client_error_kind { + ErrorKind::Io(err) => Self::IoError(err), + ErrorKind::TransactionError(err) => Self::TransactionError(err), + ErrorKind::Reqwest(err) => Self::Custom(format!("{:?}", err)), + ErrorKind::RpcError(err) => Self::Custom(format!("{:?}", err)), + ErrorKind::SerdeJson(err) => Self::Custom(format!("{:?}", err)), + ErrorKind::SigningError(err) => Self::Custom(format!("{:?}", err)), + ErrorKind::Custom(err) => Self::Custom(format!("{:?}", err)), + } + } +} + +#[derive(ThisError, Debug)] +#[error("{kind}")] +pub struct Error { + pub request: Option, + + #[source] + pub kind: ErrorKind, +} + +impl Error { + pub fn new_with_request(kind: ErrorKind, request: request::RpcRequest) -> Self { + Self { + request: Some(request), + kind, + } + } + + pub fn into_with_request(self, request: request::RpcRequest) -> Self { + Self { + request: Some(request), + ..self + } + } + + pub fn request(&self) -> Option<&request::RpcRequest> { + self.request.as_ref() + } + + pub fn kind(&self) -> &ErrorKind { + &self.kind + } + + pub fn get_transaction_error(&self) -> Option { + self.kind.get_transaction_error() + } +} + +impl From for Error { + fn from(kind: ErrorKind) -> Self { + Self { + request: None, + kind, + } + } +} + +impl From for Error { + fn from(err: TransportError) -> Self { + Self { + request: None, + kind: err.into(), + } + } +} + +impl From for TransportError { + fn from(client_error: Error) -> Self { + client_error.kind.into() + } +} + +impl From for Error { + fn from(err: std::io::Error) -> Self { + Self { + request: None, + kind: err.into(), + } + } +} + +impl From for Error { + fn from(err: reqwest::Error) -> Self { + Self { + request: None, + kind: err.into(), + } + } +} + +impl From for Error { + fn from(err: request::RpcError) -> Self { + Self { + request: None, + kind: err.into(), + } + } +} + +impl From for Error { + fn from(err: serde_json::error::Error) -> Self { + Self { + request: None, + kind: err.into(), + } + } +} + +impl From for Error { + fn from(err: SignerError) -> Self { + Self { + request: None, + kind: err.into(), + } + } +} + +impl From for Error { + fn from(err: TransactionError) -> Self { + Self { + request: None, + kind: err.into(), + } + } +} + +pub type Result = std::result::Result; diff --git a/client/src/rpc_config.rs b/rpc-client-api/src/config.rs similarity index 99% rename from client/src/rpc_config.rs rename to rpc-client-api/src/config.rs index d5bc986a21..ee98402a57 100644 --- a/client/src/rpc_config.rs +++ b/rpc-client-api/src/config.rs @@ -1,5 +1,5 @@ use { - crate::rpc_filter::RpcFilterType, + crate::filter::RpcFilterType, solana_account_decoder::{UiAccountEncoding, UiDataSliceConfig}, solana_sdk::{ clock::{Epoch, Slot}, diff --git a/client/src/rpc_custom_error.rs b/rpc-client-api/src/custom_error.rs similarity index 99% rename from client/src/rpc_custom_error.rs rename to rpc-client-api/src/custom_error.rs index 95ef60293c..33bcf9b810 100644 --- a/client/src/rpc_custom_error.rs +++ b/rpc-client-api/src/custom_error.rs @@ -1,6 +1,6 @@ //! Implementation defined RPC server errors use { - crate::rpc_response::RpcSimulateTransactionResult, + crate::response::RpcSimulateTransactionResult, jsonrpc_core::{Error, ErrorCode}, solana_sdk::clock::Slot, solana_transaction_status::EncodeError, diff --git a/client/src/rpc_deprecated_config.rs b/rpc-client-api/src/deprecated_config.rs similarity index 99% rename from client/src/rpc_deprecated_config.rs rename to rpc-client-api/src/deprecated_config.rs index 6457b5f342..ab562aa0e8 100644 --- a/client/src/rpc_deprecated_config.rs +++ b/rpc-client-api/src/deprecated_config.rs @@ -1,6 +1,6 @@ #![allow(deprecated)] use { - crate::rpc_config::{ + crate::config::{ EncodingConfig, RpcBlockConfig, RpcEncodingConfigWrapper, RpcTransactionConfig, }, solana_sdk::{clock::Slot, commitment_config::CommitmentConfig}, diff --git a/rpc-client-api/src/error_object.rs b/rpc-client-api/src/error_object.rs new file mode 100644 index 0000000000..de077587c9 --- /dev/null +++ b/rpc-client-api/src/error_object.rs @@ -0,0 +1,5 @@ +#[derive(Deserialize, Debug)] +pub struct RpcErrorObject { + pub code: i64, + pub message: String, +} diff --git a/client/src/rpc_filter.rs b/rpc-client-api/src/filter.rs similarity index 99% rename from client/src/rpc_filter.rs rename to rpc-client-api/src/filter.rs index 1f6548c80a..fe5973377d 100644 --- a/client/src/rpc_filter.rs +++ b/rpc-client-api/src/filter.rs @@ -259,7 +259,7 @@ impl From for Memcmp { } } -pub(crate) fn maybe_map_filters( +pub fn maybe_map_filters( node_version: Option, filters: &mut [RpcFilterType], ) -> Result<(), String> { diff --git a/rpc-client-api/src/lib.rs b/rpc-client-api/src/lib.rs new file mode 100644 index 0000000000..6db2639455 --- /dev/null +++ b/rpc-client-api/src/lib.rs @@ -0,0 +1,13 @@ +#![allow(clippy::integer_arithmetic)] + +pub mod client_error; +pub mod config; +pub mod custom_error; +pub mod deprecated_config; +pub mod error_object; +pub mod filter; +pub mod request; +pub mod response; + +#[macro_use] +extern crate serde_derive; diff --git a/client/src/rpc_request.rs b/rpc-client-api/src/request.rs similarity index 98% rename from client/src/rpc_request.rs rename to rpc-client-api/src/request.rs index 32f8c45183..50b713d412 100644 --- a/client/src/rpc_request.rs +++ b/rpc-client-api/src/request.rs @@ -1,5 +1,5 @@ use { - crate::rpc_response::RpcSimulateTransactionResult, + crate::response::RpcSimulateTransactionResult, serde_json::{json, Value}, solana_sdk::{clock::Slot, pubkey::Pubkey}, std::fmt, @@ -208,7 +208,7 @@ pub const MAX_GET_SLOT_LEADERS: usize = 5000; pub const DELINQUENT_VALIDATOR_SLOT_DISTANCE: u64 = 128; impl RpcRequest { - pub(crate) fn build_request_json(self, id: u64, params: Value) -> Value { + pub fn build_request_json(self, id: u64, params: Value) -> Value { let jsonrpc = "2.0"; json!({ "jsonrpc": jsonrpc, @@ -274,7 +274,7 @@ pub enum TokenAccountsFilter { mod tests { use { super::*, - crate::rpc_config::RpcTokenAccountsFilter, + crate::config::RpcTokenAccountsFilter, solana_sdk::commitment_config::{CommitmentConfig, CommitmentLevel}, }; diff --git a/client/src/rpc_response.rs b/rpc-client-api/src/response.rs similarity index 100% rename from client/src/rpc_response.rs rename to rpc-client-api/src/response.rs diff --git a/rpc-client-nonce-utils/Cargo.toml b/rpc-client-nonce-utils/Cargo.toml new file mode 100644 index 0000000000..eb431146fe --- /dev/null +++ b/rpc-client-nonce-utils/Cargo.toml @@ -0,0 +1,28 @@ +[package] +name = "solana-rpc-client-nonce-utils" +version = "1.12.0" +description = "Solana RPC Client Nonce Utilities" +authors = ["Solana Maintainers "] +repository = "https://github.com/solana-labs/solana" +license = "Apache-2.0" +homepage = "https://solana.com/" +documentation = "https://docs.rs/solana-nonce-client" +edition = "2021" + +[dependencies] +clap = "2.33.0" +solana-clap-utils = { path = "../clap-utils", version = "=1.12.0" } +solana-rpc-client = { path = "../rpc-client", version = "=1.12.0" } +solana-sdk = { path = "../sdk", version = "=1.12.0" } +thiserror = "1.0" + +[dev-dependencies] +anyhow = "1.0.58" +futures = "0.3" +serde_json = "1.0.83" +solana-account-decoder = { path = "../account-decoder", version = "=1.12.0" } +solana-rpc-client-api = { path = "../rpc-client-api", version = "=1.12.0" } +tokio = { version = "1", features = ["full"] } + +[package.metadata.docs.rs] +targets = ["x86_64-unknown-linux-gnu"] diff --git a/client/src/blockhash_query.rs b/rpc-client-nonce-utils/src/blockhash_query.rs similarity index 94% rename from client/src/blockhash_query.rs rename to rpc-client-nonce-utils/src/blockhash_query.rs index 1b630351c9..3f2b84bb34 100644 --- a/client/src/blockhash_query.rs +++ b/rpc-client-nonce-utils/src/blockhash_query.rs @@ -1,11 +1,11 @@ use { - crate::{nonce_utils, rpc_client::RpcClient}, clap::ArgMatches, solana_clap_utils::{ input_parsers::{pubkey_of, value_of}, nonce::*, offline::*, }, + solana_rpc_client::rpc_client::RpcClient, solana_sdk::{ commitment_config::CommitmentConfig, fee_calculator::FeeCalculator, hash::Hash, pubkey::Pubkey, @@ -35,8 +35,8 @@ impl Source { } Self::NonceAccount(ref pubkey) => { #[allow(clippy::redundant_closure)] - let data = nonce_utils::get_account_with_commitment(rpc_client, pubkey, commitment) - .and_then(|ref a| nonce_utils::data_from_account(a))?; + let data = crate::get_account_with_commitment(rpc_client, pubkey, commitment) + .and_then(|ref a| crate::data_from_account(a))?; Ok((data.blockhash(), data.fee_calculator)) } } @@ -61,8 +61,8 @@ impl Source { Ok(res) } Self::NonceAccount(ref pubkey) => { - let res = nonce_utils::get_account_with_commitment(rpc_client, pubkey, commitment)?; - let res = nonce_utils::data_from_account(&res)?; + let res = crate::get_account_with_commitment(rpc_client, pubkey, commitment)?; + let res = crate::data_from_account(&res)?; Ok(Some(res) .filter(|d| d.blockhash() == *blockhash) .map(|d| d.fee_calculator)) @@ -82,8 +82,8 @@ impl Source { } Self::NonceAccount(ref pubkey) => { #[allow(clippy::redundant_closure)] - let data = nonce_utils::get_account_with_commitment(rpc_client, pubkey, commitment) - .and_then(|ref a| nonce_utils::data_from_account(a))?; + let data = crate::get_account_with_commitment(rpc_client, pubkey, commitment) + .and_then(|ref a| crate::data_from_account(a))?; Ok(data.blockhash()) } } @@ -99,8 +99,8 @@ impl Source { Self::Cluster => rpc_client.is_blockhash_valid(blockhash, commitment)?, Self::NonceAccount(ref pubkey) => { #[allow(clippy::redundant_closure)] - let _ = nonce_utils::get_account_with_commitment(rpc_client, pubkey, commitment) - .and_then(|ref a| nonce_utils::data_from_account(a))?; + let _ = crate::get_account_with_commitment(rpc_client, pubkey, commitment) + .and_then(|ref a| crate::data_from_account(a))?; true } }) @@ -185,14 +185,14 @@ impl Default for BlockhashQuery { mod tests { use { super::*, - crate::{ - blockhash_query, - rpc_request::RpcRequest, - rpc_response::{Response, RpcFeeCalculator, RpcFees, RpcResponseContext}, - }, + crate::blockhash_query, clap::App, serde_json::{self, json}, solana_account_decoder::{UiAccount, UiAccountEncoding}, + solana_rpc_client_api::{ + request::RpcRequest, + response::{Response, RpcFeeCalculator, RpcFees, RpcResponseContext}, + }, solana_sdk::{ account::Account, hash::hash, diff --git a/client/src/nonce_utils.rs b/rpc-client-nonce-utils/src/lib.rs similarity index 92% rename from client/src/nonce_utils.rs rename to rpc-client-nonce-utils/src/lib.rs index b00ef416c5..f03570a6b2 100644 --- a/client/src/nonce_utils.rs +++ b/rpc-client-nonce-utils/src/lib.rs @@ -1,10 +1,13 @@ //! Durable transaction nonce helpers. -pub use crate::nonblocking::nonce_utils::{ +pub mod blockhash_query; +pub mod nonblocking; + +pub use crate::nonblocking::{ account_identity_ok, data_from_account, data_from_state, state_from_account, Error, }; use { - crate::rpc_client::RpcClient, + solana_rpc_client::rpc_client::RpcClient, solana_sdk::{account::Account, commitment_config::CommitmentConfig, pubkey::Pubkey}, }; diff --git a/client/src/nonblocking/blockhash_query.rs b/rpc-client-nonce-utils/src/nonblocking/blockhash_query.rs similarity index 96% rename from client/src/nonblocking/blockhash_query.rs rename to rpc-client-nonce-utils/src/nonblocking/blockhash_query.rs index 28943ad6a8..881f2b2d0c 100644 --- a/client/src/nonblocking/blockhash_query.rs +++ b/rpc-client-nonce-utils/src/nonblocking/blockhash_query.rs @@ -1,11 +1,12 @@ use { - crate::nonblocking::{nonce_utils, rpc_client::RpcClient}, + crate::nonblocking, clap::ArgMatches, solana_clap_utils::{ input_parsers::{pubkey_of, value_of}, nonce::*, offline::*, }, + solana_rpc_client::nonblocking::rpc_client::RpcClient, solana_sdk::{commitment_config::CommitmentConfig, hash::Hash, pubkey::Pubkey}, }; @@ -30,9 +31,9 @@ impl Source { } Self::NonceAccount(ref pubkey) => { #[allow(clippy::redundant_closure)] - let data = nonce_utils::get_account_with_commitment(rpc_client, pubkey, commitment) + let data = nonblocking::get_account_with_commitment(rpc_client, pubkey, commitment) .await - .and_then(|ref a| nonce_utils::data_from_account(a))?; + .and_then(|ref a| nonblocking::data_from_account(a))?; Ok(data.blockhash()) } } @@ -48,9 +49,9 @@ impl Source { Self::Cluster => rpc_client.is_blockhash_valid(blockhash, commitment).await?, Self::NonceAccount(ref pubkey) => { #[allow(clippy::redundant_closure)] - let _ = nonce_utils::get_account_with_commitment(rpc_client, pubkey, commitment) + let _ = nonblocking::get_account_with_commitment(rpc_client, pubkey, commitment) .await - .and_then(|ref a| nonce_utils::data_from_account(a))?; + .and_then(|ref a| nonblocking::data_from_account(a))?; true } }) @@ -115,14 +116,14 @@ impl Default for BlockhashQuery { mod tests { use { super::*, - crate::{ - nonblocking::blockhash_query, - rpc_request::RpcRequest, - rpc_response::{Response, RpcBlockhash, RpcResponseContext}, - }, + crate::nonblocking::blockhash_query, clap::App, serde_json::{self, json}, solana_account_decoder::{UiAccount, UiAccountEncoding}, + solana_rpc_client_api::{ + request::RpcRequest, + response::{Response, RpcBlockhash, RpcResponseContext}, + }, solana_sdk::{ account::Account, fee_calculator::FeeCalculator, diff --git a/client/src/nonblocking/nonce_utils.rs b/rpc-client-nonce-utils/src/nonblocking/mod.rs similarity index 94% rename from client/src/nonblocking/nonce_utils.rs rename to rpc-client-nonce-utils/src/nonblocking/mod.rs index fe0d2216d5..4b8b0893dc 100644 --- a/client/src/nonblocking/nonce_utils.rs +++ b/rpc-client-nonce-utils/src/nonblocking/mod.rs @@ -1,7 +1,9 @@ //! Durable transaction nonce helpers. +pub mod blockhash_query; + use { - crate::nonblocking::rpc_client::RpcClient, + solana_rpc_client::nonblocking::rpc_client::RpcClient, solana_sdk::{ account::{Account, ReadableAccount}, account_utils::StateMut, @@ -97,10 +99,8 @@ pub fn account_identity_ok(account: &T) -> Result<(), Error> /// Determine if a nonce account is initialized: /// /// ```no_run -/// use solana_client::nonblocking::{ -/// rpc_client::RpcClient, -/// nonce_utils, -/// }; +/// use solana_rpc_client_nonce_utils::nonblocking; +/// use solana_rpc_client::nonblocking::rpc_client::RpcClient; /// use solana_sdk::{ /// nonce::State, /// pubkey::Pubkey, @@ -116,7 +116,7 @@ pub fn account_identity_ok(account: &T) -> Result<(), Error> /// // Sign the tx with nonce_account's `blockhash` instead of the /// // network's latest blockhash. /// let nonce_account = client.get_account(nonce_account_pubkey).await?; -/// let nonce_state = nonce_utils::state_from_account(&nonce_account)?; +/// let nonce_state = nonblocking::state_from_account(&nonce_account)?; /// /// Ok(!matches!(nonce_state, State::Uninitialized)) /// } @@ -149,10 +149,8 @@ pub fn state_from_account>( /// Create and sign a transaction with a durable nonce: /// /// ```no_run -/// use solana_client::nonblocking::{ -/// rpc_client::RpcClient, -/// nonce_utils, -/// }; +/// use solana_rpc_client_nonce_utils::nonblocking; +/// use solana_rpc_client::nonblocking::rpc_client::RpcClient; /// use solana_sdk::{ /// message::Message, /// pubkey::Pubkey, @@ -201,7 +199,7 @@ pub fn state_from_account>( /// // Sign the tx with nonce_account's `blockhash` instead of the /// // network's latest blockhash. /// let nonce_account = client.get_account(nonce_account_pubkey).await?; -/// let nonce_data = nonce_utils::data_from_account(&nonce_account)?; +/// let nonce_data = nonblocking::data_from_account(&nonce_account)?; /// let blockhash = nonce_data.blockhash(); /// /// tx.try_sign(&[payer], blockhash)?; diff --git a/rpc-client/Cargo.toml b/rpc-client/Cargo.toml new file mode 100644 index 0000000000..45f2a34656 --- /dev/null +++ b/rpc-client/Cargo.toml @@ -0,0 +1,40 @@ +[package] +name = "solana-rpc-client" +version = "1.12.0" +description = "Solana RPC Client" +authors = ["Solana Maintainers "] +repository = "https://github.com/solana-labs/solana" +license = "Apache-2.0" +homepage = "https://solana.com/" +documentation = "https://docs.rs/solana-rpc-client" +edition = "2021" + +[dependencies] +async-trait = "0.1.57" +base64 = "0.13.0" +bincode = "1.3.3" +bs58 = "0.4.0" +indicatif = "0.17.0" +log = "0.4.17" +reqwest = { version = "0.11.11", default-features = false, features = ["blocking", "brotli", "deflate", "gzip", "rustls-tls", "json"] } +semver = "1.0.13" +serde = "1.0.143" +serde_derive = "1.0.103" +serde_json = "1.0.83" +solana-account-decoder = { path = "../account-decoder", version = "=1.12.0" } +solana-rpc-client-api = { path = "../rpc-client-api", version = "=1.12.0" } +solana-sdk = { path = "../sdk", version = "=1.12.0" } +solana-transaction-status = { path = "../transaction-status", version = "=1.12.0" } +solana-version = { path = "../version", version = "=1.12.0" } +solana-vote-program = { path = "../programs/vote", version = "=1.12.0" } +tokio = { version = "1", features = ["full"] } + +[dev-dependencies] +assert_matches = "1.5.0" +crossbeam-channel = "0.5" +futures = "0.3" +jsonrpc-core = "18.0.0" +jsonrpc-http-server = "18.0.0" + +[package.metadata.docs.rs] +targets = ["x86_64-unknown-linux-gnu"] diff --git a/client/src/http_sender.rs b/rpc-client/src/http_sender.rs similarity index 91% rename from client/src/http_sender.rs rename to rpc-client/src/http_sender.rs index 84e1418d7a..3b488a0af6 100644 --- a/client/src/http_sender.rs +++ b/rpc-client/src/http_sender.rs @@ -1,13 +1,7 @@ //! Nonblocking [`RpcSender`] over HTTP. use { - crate::{ - client_error::Result, - rpc_custom_error, - rpc_request::{RpcError, RpcRequest, RpcResponseErrorData}, - rpc_response::RpcSimulateTransactionResult, - rpc_sender::*, - }, + crate::rpc_sender::*, async_trait::async_trait, log::*, reqwest::{ @@ -15,6 +9,13 @@ use { header::{self, CONTENT_TYPE, RETRY_AFTER}, StatusCode, }, + solana_rpc_client_api::{ + client_error::Result, + custom_error, + error_object::RpcErrorObject, + request::{RpcError, RpcRequest, RpcResponseErrorData}, + response::RpcSimulateTransactionResult, + }, std::{ sync::{ atomic::{AtomicU64, Ordering}, @@ -72,12 +73,6 @@ impl HttpSender { } } -#[derive(Deserialize, Debug)] -pub(crate) struct RpcErrorObject { - pub code: i64, - pub message: String, -} - struct StatsUpdater<'a> { stats: &'a RwLock, request_start_time: Instant, @@ -169,7 +164,7 @@ impl RpcSender for HttpSender { return match serde_json::from_value::(json["error"].clone()) { Ok(rpc_error_object) => { let data = match rpc_error_object.code { - rpc_custom_error::JSON_RPC_SERVER_ERROR_SEND_TRANSACTION_PREFLIGHT_FAILURE => { + custom_error::JSON_RPC_SERVER_ERROR_SEND_TRANSACTION_PREFLIGHT_FAILURE => { match serde_json::from_value::(json["error"]["data"].clone()) { Ok(data) => RpcResponseErrorData::SendTransactionPreflightFailure(data), Err(err) => { @@ -178,9 +173,9 @@ impl RpcSender for HttpSender { } } }, - rpc_custom_error::JSON_RPC_SERVER_ERROR_NODE_UNHEALTHY => { - match serde_json::from_value::(json["error"]["data"].clone()) { - Ok(rpc_custom_error::NodeUnhealthyErrorData {num_slots_behind}) => RpcResponseErrorData::NodeUnhealthy {num_slots_behind}, + custom_error::JSON_RPC_SERVER_ERROR_NODE_UNHEALTHY => { + match serde_json::from_value::(json["error"]["data"].clone()) { + Ok(custom_error::NodeUnhealthyErrorData {num_slots_behind}) => RpcResponseErrorData::NodeUnhealthy {num_slots_behind}, Err(_err) => { RpcResponseErrorData::Empty } diff --git a/rpc-client/src/lib.rs b/rpc-client/src/lib.rs new file mode 100644 index 0000000000..43c15d8765 --- /dev/null +++ b/rpc-client/src/lib.rs @@ -0,0 +1,15 @@ +#![allow(clippy::integer_arithmetic)] + +pub mod http_sender; +pub mod mock_sender; +pub mod nonblocking; +pub mod rpc_client; +pub mod rpc_sender; +pub mod spinner; + +pub mod mock_sender_for_cli { + /// Magic `SIGNATURE` value used by `solana-cli` unit tests. + /// Please don't use this constant. + pub const SIGNATURE: &str = + "43yNSFC6fYTuPgTNFFhF4axw7AfWxB2BPdurme8yrsWEYwm8299xh8n6TAHjGymiSub1XtyxTNyd9GBfY2hxoBw8"; +} diff --git a/client/src/mock_sender.rs b/rpc-client/src/mock_sender.rs similarity index 99% rename from client/src/mock_sender.rs rename to rpc-client/src/mock_sender.rs index 8ab244a299..afea966530 100644 --- a/client/src/mock_sender.rs +++ b/rpc-client/src/mock_sender.rs @@ -1,11 +1,15 @@ //! A nonblocking [`RpcSender`] used for unit testing [`RpcClient`](crate::rpc_client::RpcClient). use { - crate::{ + crate::rpc_sender::*, + async_trait::async_trait, + serde_json::{json, Number, Value}, + solana_account_decoder::{UiAccount, UiAccountEncoding}, + solana_rpc_client_api::{ client_error::Result, - rpc_config::RpcBlockProductionConfig, - rpc_request::RpcRequest, - rpc_response::{ + config::RpcBlockProductionConfig, + request::RpcRequest, + response::{ Response, RpcAccountBalance, RpcBlockProduction, RpcBlockProductionRange, RpcBlockhash, RpcConfirmedTransactionStatusWithSignature, RpcContactInfo, RpcFees, RpcIdentity, RpcInflationGovernor, RpcInflationRate, RpcInflationReward, RpcKeyedAccount, @@ -13,11 +17,7 @@ use { RpcStakeActivation, RpcSupply, RpcVersionInfo, RpcVoteAccountInfo, RpcVoteAccountStatus, StakeActivationState, }, - rpc_sender::*, }, - async_trait::async_trait, - serde_json::{json, Number, Value}, - solana_account_decoder::{UiAccount, UiAccountEncoding}, solana_sdk::{ account::Account, clock::{Slot, UnixTimestamp}, diff --git a/rpc-client/src/nonblocking/mod.rs b/rpc-client/src/nonblocking/mod.rs new file mode 100644 index 0000000000..9fa9f86a74 --- /dev/null +++ b/rpc-client/src/nonblocking/mod.rs @@ -0,0 +1 @@ +pub mod rpc_client; diff --git a/client/src/nonblocking/rpc_client.rs b/rpc-client/src/nonblocking/rpc_client.rs similarity index 90% rename from client/src/nonblocking/rpc_client.rs rename to rpc-client/src/nonblocking/rpc_client.rs index ead129fa26..9e1a5c2b18 100644 --- a/client/src/nonblocking/rpc_client.rs +++ b/rpc-client/src/nonblocking/rpc_client.rs @@ -8,20 +8,15 @@ pub use crate::mock_sender::Mocks; #[allow(deprecated)] -use crate::rpc_deprecated_config::{ +use solana_rpc_client_api::deprecated_config::{ RpcConfirmedBlockConfig, RpcConfirmedTransactionConfig, RpcGetConfirmedSignaturesForAddress2Config, }; use { crate::{ - client_error::{ClientError, ClientErrorKind, Result as ClientResult}, http_sender::HttpSender, mock_sender::MockSender, rpc_client::{GetConfirmedSignaturesForAddress2Config, RpcClientConfig}, - rpc_config::{RpcAccountInfoConfig, *}, - rpc_filter::{self, RpcFilterType}, - rpc_request::{RpcError, RpcRequest, RpcResponseErrorData, TokenAccountsFilter}, - rpc_response::*, rpc_sender::*, spinner, }, @@ -32,6 +27,15 @@ use { parse_token::{TokenAccountType, UiTokenAccount, UiTokenAmount}, UiAccount, UiAccountData, UiAccountEncoding, }, + solana_rpc_client_api::{ + client_error::{ + Error as ClientError, ErrorKind as ClientErrorKind, Result as ClientResult, + }, + config::{RpcAccountInfoConfig, *}, + filter::{self, RpcFilterType}, + request::{RpcError, RpcRequest, RpcResponseErrorData, TokenAccountsFilter}, + response::*, + }, solana_sdk::{ account::Account, clock::{Epoch, Slot, UnixTimestamp, DEFAULT_MS_PER_SLOT, MAX_HASH_AGE_IN_SECONDS}, @@ -105,19 +109,19 @@ use { /// # Errors /// /// Methods on `RpcClient` return -/// [`client_error::Result`][crate::client_error::Result], and many of them -/// return the [`RpcResult`][crate::rpc_response::RpcResult] typedef, which -/// contains [`Response`][crate::rpc_response::Response] on `Ok`. Both +/// [`client_error::Result`][solana_rpc_client_api::client_error::Result], and many of them +/// return the [`RpcResult`][solana_rpc_client_api::response::RpcResult] typedef, which +/// contains [`Response`][solana_rpc_client_api::response::Response] on `Ok`. Both /// `client_error::Result` and [`RpcResult`] contain `ClientError` on error. In /// the case of `RpcResult`, the actual return value is in the -/// [`value`][crate::rpc_response::Response::value] field, with RPC contextual -/// information in the [`context`][crate::rpc_response::Response::context] +/// [`value`][solana_rpc_client_api::response::Response::value] field, with RPC contextual +/// information in the [`context`][solana_rpc_client_api::response::Response::context] /// field, so it is common for the value to be accessed with `?.value`, as in /// /// ``` /// # use solana_sdk::system_transaction; -/// # use solana_client::rpc_client::RpcClient; -/// # use solana_client::client_error::ClientError; +/// # use solana_rpc_client_api::client_error::Error; +/// # use solana_rpc_client::rpc_client::RpcClient; /// # use solana_sdk::signature::{Keypair, Signer}; /// # use solana_sdk::hash::Hash; /// # let rpc_client = RpcClient::new_mock("succeeds".to_string()); @@ -128,13 +132,13 @@ use { /// # let tx = system_transaction::transfer(&key, &to, lamports, latest_blockhash); /// let signature = rpc_client.send_transaction(&tx)?; /// let statuses = rpc_client.get_signature_statuses(&[signature])?.value; -/// # Ok::<(), ClientError>(()) +/// # Ok::<(), Error>(()) /// ``` /// /// Requests may timeout, in which case they return a [`ClientError`] where the /// [`ClientErrorKind`] is [`ClientErrorKind::Reqwest`], and where the interior -/// [`reqwest::Error`](crate::client_error::reqwest::Error)s -/// [`is_timeout`](crate::client_error::reqwest::Error::is_timeout) method +/// [`reqwest::Error`](solana_rpc_client_api::client_error::reqwest::Error)s +/// [`is_timeout`](solana_rpc_client_api::client_error::reqwest::Error::is_timeout) method /// returns `true`. The default timeout is 30 seconds, and may be changed by /// calling an appropriate constructor with a `timeout` parameter. pub struct RpcClient { @@ -174,7 +178,7 @@ impl RpcClient { /// # Examples /// /// ``` - /// # use solana_client::nonblocking::rpc_client::RpcClient; + /// # use solana_rpc_client::nonblocking::rpc_client::RpcClient; /// let url = "http://localhost:8899".to_string(); /// let client = RpcClient::new(url); /// ``` @@ -196,7 +200,7 @@ impl RpcClient { /// /// ``` /// # use solana_sdk::commitment_config::CommitmentConfig; - /// # use solana_client::nonblocking::rpc_client::RpcClient; + /// # use solana_rpc_client::nonblocking::rpc_client::RpcClient; /// let url = "http://localhost:8899".to_string(); /// let commitment_config = CommitmentConfig::processed(); /// let client = RpcClient::new_with_commitment(url, commitment_config); @@ -222,7 +226,7 @@ impl RpcClient { /// /// ``` /// # use std::time::Duration; - /// # use solana_client::nonblocking::rpc_client::RpcClient; + /// # use solana_rpc_client::nonblocking::rpc_client::RpcClient; /// let url = "http://localhost::8899".to_string(); /// let timeout = Duration::from_secs(1); /// let client = RpcClient::new_with_timeout(url, timeout); @@ -245,7 +249,7 @@ impl RpcClient { /// /// ``` /// # use std::time::Duration; - /// # use solana_client::nonblocking::rpc_client::RpcClient; + /// # use solana_rpc_client::nonblocking::rpc_client::RpcClient; /// # use solana_sdk::commitment_config::CommitmentConfig; /// let url = "http://localhost::8899".to_string(); /// let timeout = Duration::from_secs(1); @@ -286,7 +290,7 @@ impl RpcClient { /// /// ``` /// # use std::time::Duration; - /// # use solana_client::nonblocking::rpc_client::RpcClient; + /// # use solana_rpc_client::nonblocking::rpc_client::RpcClient; /// # use solana_sdk::commitment_config::CommitmentConfig; /// let url = "http://localhost::8899".to_string(); /// let timeout = Duration::from_secs(1); @@ -348,14 +352,14 @@ impl RpcClient { /// # Examples /// /// ``` - /// # use solana_client::nonblocking::rpc_client::RpcClient; + /// # use solana_rpc_client::nonblocking::rpc_client::RpcClient; /// // Create an `RpcClient` that always succeeds /// let url = "succeeds".to_string(); /// let successful_client = RpcClient::new_mock(url); /// ``` /// /// ``` - /// # use solana_client::nonblocking::rpc_client::RpcClient; + /// # use solana_rpc_client::nonblocking::rpc_client::RpcClient; /// // Create an `RpcClient` that always fails /// let url = "fails".to_string(); /// let successful_client = RpcClient::new_mock(url); @@ -410,11 +414,11 @@ impl RpcClient { /// # Examples /// /// ``` - /// # use solana_client::{ - /// # nonblocking::rpc_client::RpcClient, - /// # rpc_request::RpcRequest, - /// # rpc_response::{Response, RpcResponseContext}, + /// # use solana_rpc_client_api::{ + /// # request::RpcRequest, + /// # response::{Response, RpcResponseContext}, /// # }; + /// # use solana_rpc_client::nonblocking::rpc_client::RpcClient; /// # use std::collections::HashMap; /// # use serde_json::json; /// // Create a mock with a custom repsonse to the `GetBalance` request @@ -447,7 +451,7 @@ impl RpcClient { /// /// ``` /// # use std::net::SocketAddr; - /// # use solana_client::nonblocking::rpc_client::RpcClient; + /// # use solana_rpc_client::nonblocking::rpc_client::RpcClient; /// let addr = SocketAddr::from(([127, 0, 0, 1], 8899)); /// let client = RpcClient::new_socket(addr); /// ``` @@ -466,7 +470,7 @@ impl RpcClient { /// /// ``` /// # use std::net::SocketAddr; - /// # use solana_client::nonblocking::rpc_client::RpcClient; + /// # use solana_rpc_client::nonblocking::rpc_client::RpcClient; /// # use solana_sdk::commitment_config::CommitmentConfig; /// let addr = SocketAddr::from(([127, 0, 0, 1], 8899)); /// let commitment_config = CommitmentConfig::processed(); @@ -493,7 +497,7 @@ impl RpcClient { /// ``` /// # use std::net::SocketAddr; /// # use std::time::Duration; - /// # use solana_client::nonblocking::rpc_client::RpcClient; + /// # use solana_rpc_client::nonblocking::rpc_client::RpcClient; /// let addr = SocketAddr::from(([127, 0, 0, 1], 8899)); /// let timeout = Duration::from_secs(1); /// let client = RpcClient::new_socket_with_timeout(addr, timeout); @@ -586,7 +590,7 @@ impl RpcClient { mut filters: Vec, ) -> Result, RpcError> { let node_version = self.get_node_version().await?; - rpc_filter::maybe_map_filters(Some(node_version), &mut filters) + filter::maybe_map_filters(Some(node_version), &mut filters) .map_err(RpcError::RpcRequestError)?; Ok(filters) } @@ -617,9 +621,9 @@ impl RpcClient { /// [`JSON_RPC_SERVER_ERROR_NODE_UNHEALTHY`]. /// /// [`RpcResponseError`]: RpcError::RpcResponseError - /// [`JSON_RPC_SERVER_ERROR_TRANSACTION_SIGNATURE_VERIFICATION_FAILURE`]: crate::rpc_custom_error::JSON_RPC_SERVER_ERROR_TRANSACTION_SIGNATURE_VERIFICATION_FAILURE - /// [`JSON_RPC_SERVER_ERROR_SEND_TRANSACTION_PREFLIGHT_FAILURE`]: crate::rpc_custom_error::JSON_RPC_SERVER_ERROR_SEND_TRANSACTION_PREFLIGHT_FAILURE - /// [`JSON_RPC_SERVER_ERROR_NODE_UNHEALTHY`]: crate::rpc_custom_error::JSON_RPC_SERVER_ERROR_NODE_UNHEALTHY + /// [`JSON_RPC_SERVER_ERROR_TRANSACTION_SIGNATURE_VERIFICATION_FAILURE`]: solana_rpc_client_api::custom_error::JSON_RPC_SERVER_ERROR_TRANSACTION_SIGNATURE_VERIFICATION_FAILURE + /// [`JSON_RPC_SERVER_ERROR_SEND_TRANSACTION_PREFLIGHT_FAILURE`]: solana_rpc_client_api::custom_error::JSON_RPC_SERVER_ERROR_SEND_TRANSACTION_PREFLIGHT_FAILURE + /// [`JSON_RPC_SERVER_ERROR_NODE_UNHEALTHY`]: solana_rpc_client_api::custom_error::JSON_RPC_SERVER_ERROR_NODE_UNHEALTHY /// /// # RPC Reference /// @@ -632,10 +636,8 @@ impl RpcClient { /// # Examples /// /// ``` - /// # use solana_client::{ - /// # nonblocking::rpc_client::RpcClient, - /// # client_error::ClientError, - /// # }; + /// # use solana_rpc_client_api::client_error::Error; + /// # use solana_rpc_client::nonblocking::rpc_client::RpcClient; /// # use solana_sdk::{ /// # signature::Signer, /// # signature::Signature, @@ -650,9 +652,9 @@ impl RpcClient { /// # let latest_blockhash = rpc_client.get_latest_blockhash().await?; /// let tx = system_transaction::transfer(&alice, &bob.pubkey(), lamports, latest_blockhash); /// let signature = rpc_client.send_and_confirm_transaction(&tx).await?; - /// # Ok::<(), ClientError>(()) + /// # Ok::<(), Error>(()) /// # })?; - /// # Ok::<(), ClientError>(()) + /// # Ok::<(), Error>(()) /// ``` pub async fn send_and_confirm_transaction( &self, @@ -769,8 +771,8 @@ impl RpcClient { /// method. /// /// [`send_transaction_with_config`]: RpcClient::send_transaction_with_config - /// [`skip_preflight`]: crate::rpc_config::RpcSendTransactionConfig::skip_preflight - /// [`RpcSendTransactionConfig`]: crate::rpc_config::RpcSendTransactionConfig + /// [`skip_preflight`]: solana_rpc_client_api::config::RpcSendTransactionConfig::skip_preflight + /// [`RpcSendTransactionConfig`]: solana_rpc_client_api::config::RpcSendTransactionConfig /// [`send_and_confirm_transaction`]: RpcClient::send_and_confirm_transaction /// /// # Errors @@ -789,9 +791,9 @@ impl RpcClient { /// [`JSON_RPC_SERVER_ERROR_NODE_UNHEALTHY`]. /// /// [`RpcResponseError`]: RpcError::RpcResponseError - /// [`JSON_RPC_SERVER_ERROR_TRANSACTION_SIGNATURE_VERIFICATION_FAILURE`]: crate::rpc_custom_error::JSON_RPC_SERVER_ERROR_TRANSACTION_SIGNATURE_VERIFICATION_FAILURE - /// [`JSON_RPC_SERVER_ERROR_SEND_TRANSACTION_PREFLIGHT_FAILURE`]: crate::rpc_custom_error::JSON_RPC_SERVER_ERROR_SEND_TRANSACTION_PREFLIGHT_FAILURE - /// [`JSON_RPC_SERVER_ERROR_NODE_UNHEALTHY`]: crate::rpc_custom_error::JSON_RPC_SERVER_ERROR_NODE_UNHEALTHY + /// [`JSON_RPC_SERVER_ERROR_TRANSACTION_SIGNATURE_VERIFICATION_FAILURE`]: solana_rpc_client_api::custom_error::JSON_RPC_SERVER_ERROR_TRANSACTION_SIGNATURE_VERIFICATION_FAILURE + /// [`JSON_RPC_SERVER_ERROR_SEND_TRANSACTION_PREFLIGHT_FAILURE`]: solana_rpc_client_api::custom_error::JSON_RPC_SERVER_ERROR_SEND_TRANSACTION_PREFLIGHT_FAILURE + /// [`JSON_RPC_SERVER_ERROR_NODE_UNHEALTHY`]: solana_rpc_client_api::custom_error::JSON_RPC_SERVER_ERROR_NODE_UNHEALTHY /// /// # RPC Reference /// @@ -802,10 +804,8 @@ impl RpcClient { /// # Examples /// /// ``` - /// # use solana_client::{ - /// # client_error::ClientError, - /// # nonblocking::rpc_client::RpcClient, - /// # }; + /// # use solana_rpc_client_api::client_error::Error; + /// # use solana_rpc_client::nonblocking::rpc_client::RpcClient; /// # use solana_sdk::{ /// # signature::Signer, /// # signature::Signature, @@ -822,9 +822,9 @@ impl RpcClient { /// let latest_blockhash = rpc_client.get_latest_blockhash().await?; /// let tx = system_transaction::transfer(&alice, &bob.pubkey(), lamports, latest_blockhash); /// let signature = rpc_client.send_transaction(&tx).await?; - /// # Ok::<(), ClientError>(()) + /// # Ok::<(), Error>(()) /// # })?; - /// # Ok::<(), ClientError>(()) + /// # Ok::<(), Error>(()) /// ``` pub async fn send_transaction(&self, transaction: &Transaction) -> ClientResult { self.send_transaction_with_config( @@ -855,8 +855,8 @@ impl RpcClient { /// method. /// /// [`send_transaction_with_config`]: RpcClient::send_transaction_with_config - /// [`skip_preflight`]: crate::rpc_config::RpcSendTransactionConfig::skip_preflight - /// [`RpcSendTransactionConfig`]: crate::rpc_config::RpcSendTransactionConfig + /// [`skip_preflight`]: solana_rpc_client_api::config::RpcSendTransactionConfig::skip_preflight + /// [`RpcSendTransactionConfig`]: solana_rpc_client_api::config::RpcSendTransactionConfig /// [`send_and_confirm_transaction`]: RpcClient::send_and_confirm_transaction /// /// # Errors @@ -877,9 +877,9 @@ impl RpcClient { /// [`JSON_RPC_SERVER_ERROR_NODE_UNHEALTHY`]. /// /// [`RpcResponseError`]: RpcError::RpcResponseError - /// [`JSON_RPC_SERVER_ERROR_TRANSACTION_SIGNATURE_VERIFICATION_FAILURE`]: crate::rpc_custom_error::JSON_RPC_SERVER_ERROR_TRANSACTION_SIGNATURE_VERIFICATION_FAILURE - /// [`JSON_RPC_SERVER_ERROR_SEND_TRANSACTION_PREFLIGHT_FAILURE`]: crate::rpc_custom_error::JSON_RPC_SERVER_ERROR_SEND_TRANSACTION_PREFLIGHT_FAILURE - /// [`JSON_RPC_SERVER_ERROR_NODE_UNHEALTHY`]: crate::rpc_custom_error::JSON_RPC_SERVER_ERROR_NODE_UNHEALTHY + /// [`JSON_RPC_SERVER_ERROR_TRANSACTION_SIGNATURE_VERIFICATION_FAILURE`]: solana_rpc_client_api::custom_error::JSON_RPC_SERVER_ERROR_TRANSACTION_SIGNATURE_VERIFICATION_FAILURE + /// [`JSON_RPC_SERVER_ERROR_SEND_TRANSACTION_PREFLIGHT_FAILURE`]: solana_rpc_client_api::custom_error::JSON_RPC_SERVER_ERROR_SEND_TRANSACTION_PREFLIGHT_FAILURE + /// [`JSON_RPC_SERVER_ERROR_NODE_UNHEALTHY`]: solana_rpc_client_api::custom_error::JSON_RPC_SERVER_ERROR_NODE_UNHEALTHY /// /// # RPC Reference /// @@ -890,11 +890,11 @@ impl RpcClient { /// # Examples /// /// ``` - /// # use solana_client::{ - /// # client_error::ClientError, - /// # nonblocking::rpc_client::RpcClient, - /// # rpc_config::RpcSendTransactionConfig, + /// # use solana_rpc_client_api::{ + /// # client_error::Error, + /// # config::RpcSendTransactionConfig, /// # }; + /// # use solana_rpc_client::nonblocking::rpc_client::RpcClient; /// # use solana_sdk::{ /// # signature::Signer, /// # signature::Signature, @@ -918,9 +918,9 @@ impl RpcClient { /// &tx, /// config, /// ).await?; - /// # Ok::<(), ClientError>(()) + /// # Ok::<(), Error>(()) /// # })?; - /// # Ok::<(), ClientError>(()) + /// # Ok::<(), Error>(()) /// ``` pub async fn send_transaction_with_config( &self, @@ -1017,10 +1017,8 @@ impl RpcClient { /// # Examples /// /// ``` - /// # use solana_client::{ - /// # client_error::ClientError, - /// # nonblocking::rpc_client::RpcClient, - /// # }; + /// # use solana_rpc_client_api::client_error::Error; + /// # use solana_rpc_client::nonblocking::rpc_client::RpcClient; /// # use solana_sdk::{ /// # signature::Signer, /// # signature::Signature, @@ -1043,9 +1041,9 @@ impl RpcClient { /// break; /// } /// } - /// # Ok::<(), ClientError>(()) + /// # Ok::<(), Error>(()) /// # })?; - /// # Ok::<(), ClientError>(()) + /// # Ok::<(), Error>(()) /// ``` pub async fn confirm_transaction(&self, signature: &Signature) -> ClientResult { Ok(self @@ -1078,10 +1076,8 @@ impl RpcClient { /// # Examples /// /// ``` - /// # use solana_client::{ - /// # client_error::ClientError, - /// # nonblocking::rpc_client::RpcClient, - /// # }; + /// # use solana_rpc_client_api::client_error::Error; + /// # use solana_rpc_client::nonblocking::rpc_client::RpcClient; /// # use solana_sdk::{ /// # commitment_config::CommitmentConfig, /// # signature::Signer, @@ -1107,9 +1103,9 @@ impl RpcClient { /// break; /// } /// } - /// # Ok::<(), ClientError>(()) + /// # Ok::<(), Error>(()) /// # })?; - /// # Ok::<(), ClientError>(()) + /// # Ok::<(), Error>(()) /// ``` pub async fn confirm_transaction_with_commitment( &self, @@ -1237,8 +1233,8 @@ impl RpcClient { /// [`RpcSimulateTransactionResult`] will be `Some`. Any logs emitted from /// the transaction are returned in the [`logs`] field. /// - /// [`err`]: crate::rpc_response::RpcSimulateTransactionResult::err - /// [`logs`]: crate::rpc_response::RpcSimulateTransactionResult::logs + /// [`err`]: solana_rpc_client_api::response::RpcSimulateTransactionResult::err + /// [`logs`]: solana_rpc_client_api::response::RpcSimulateTransactionResult::logs /// /// Simulating a transaction is similar to the ["preflight check"] that is /// run by default when sending a transaction. @@ -1251,7 +1247,7 @@ impl RpcClient { /// `true`. /// /// [`simulate_transaction_with_config`]: RpcClient::simulate_transaction_with_config - /// [`sig_verify`]: crate::rpc_config::RpcSimulateTransactionConfig::sig_verify + /// [`sig_verify`]: solana_rpc_client_api::config::RpcSimulateTransactionConfig::sig_verify /// /// # RPC Reference /// @@ -1262,11 +1258,11 @@ impl RpcClient { /// # Examples /// /// ``` - /// # use solana_client::{ - /// # client_error::ClientError, - /// # nonblocking::rpc_client::RpcClient, - /// # rpc_response::RpcSimulateTransactionResult, + /// # use solana_rpc_client_api::{ + /// # client_error::Error, + /// # response::RpcSimulateTransactionResult, /// # }; + /// # use solana_rpc_client::nonblocking::rpc_client::RpcClient; /// # use solana_sdk::{ /// # signature::Signer, /// # signature::Signature, @@ -1284,9 +1280,9 @@ impl RpcClient { /// let tx = system_transaction::transfer(&alice, &bob.pubkey(), lamports, latest_blockhash); /// let result = rpc_client.simulate_transaction(&tx).await?; /// assert!(result.value.err.is_none()); - /// # Ok::<(), ClientError>(()) + /// # Ok::<(), Error>(()) /// # })?; - /// # Ok::<(), ClientError>(()) + /// # Ok::<(), Error>(()) /// ``` pub async fn simulate_transaction( &self, @@ -1308,8 +1304,8 @@ impl RpcClient { /// [`RpcSimulateTransactionResult`] will be `Some`. Any logs emitted from /// the transaction are returned in the [`logs`] field. /// - /// [`err`]: crate::rpc_response::RpcSimulateTransactionResult::err - /// [`logs`]: crate::rpc_response::RpcSimulateTransactionResult::logs + /// [`err`]: solana_rpc_client_api::response::RpcSimulateTransactionResult::err + /// [`logs`]: solana_rpc_client_api::response::RpcSimulateTransactionResult::logs /// /// Simulating a transaction is similar to the ["preflight check"] that is /// run by default when sending a transaction. @@ -1322,7 +1318,7 @@ impl RpcClient { /// `true`. /// /// [`simulate_transaction_with_config`]: RpcClient::simulate_transaction_with_config - /// [`sig_verify`]: crate::rpc_config::RpcSimulateTransactionConfig::sig_verify + /// [`sig_verify`]: solana_rpc_client_api::config::RpcSimulateTransactionConfig::sig_verify /// /// This method can additionally query information about accounts by /// including them in the [`accounts`] field of the @@ -1330,8 +1326,8 @@ impl RpcClient { /// are reported in the [`accounts`][accounts2] field of the returned /// [`RpcSimulateTransactionResult`]. /// - /// [`accounts`]: crate::rpc_config::RpcSimulateTransactionConfig::accounts - /// [accounts2]: crate::rpc_response::RpcSimulateTransactionResult::accounts + /// [`accounts`]: solana_rpc_client_api::config::RpcSimulateTransactionConfig::accounts + /// [accounts2]: solana_rpc_client_api::response::RpcSimulateTransactionResult::accounts /// /// # RPC Reference /// @@ -1342,12 +1338,12 @@ impl RpcClient { /// # Examples /// /// ``` - /// # use solana_client::{ - /// # client_error::ClientError, - /// # nonblocking::rpc_client::RpcClient, - /// # rpc_config::RpcSimulateTransactionConfig, - /// # rpc_response::RpcSimulateTransactionResult, + /// # use solana_rpc_client_api::{ + /// # client_error::Error, + /// # config::RpcSimulateTransactionConfig, + /// # response::RpcSimulateTransactionResult, /// # }; + /// # use solana_rpc_client::nonblocking::rpc_client::RpcClient; /// # use solana_sdk::{ /// # signature::Signer, /// # signer::keypair::Keypair, @@ -1371,9 +1367,9 @@ impl RpcClient { /// config, /// ).await?; /// assert!(result.value.err.is_none()); - /// # Ok::<(), ClientError>(()) + /// # Ok::<(), Error>(()) /// # })?; - /// # Ok::<(), ClientError>(()) + /// # Ok::<(), Error>(()) /// ``` pub async fn simulate_transaction_with_config( &self, @@ -1414,16 +1410,14 @@ impl RpcClient { /// # Examples /// /// ``` - /// # use solana_client::{ - /// # nonblocking::rpc_client::RpcClient, - /// # client_error::ClientError, - /// # }; + /// # use solana_rpc_client_api::client_error::Error; + /// # use solana_rpc_client::nonblocking::rpc_client::RpcClient; /// # futures::executor::block_on(async { /// # let rpc_client = RpcClient::new_mock("succeeds".to_string()); /// let snapshot_slot_info = rpc_client.get_highest_snapshot_slot().await?; - /// # Ok::<(), ClientError>(()) + /// # Ok::<(), Error>(()) /// # })?; - /// # Ok::<(), ClientError>(()) + /// # Ok::<(), Error>(()) /// ``` pub async fn get_highest_snapshot_slot(&self) -> ClientResult { if self.get_node_version().await? < semver::Version::new(1, 9, 0) { @@ -1482,10 +1476,8 @@ impl RpcClient { /// # Examples /// /// ``` - /// # use solana_client::{ - /// # nonblocking::rpc_client::RpcClient, - /// # client_error::ClientError, - /// # }; + /// # use solana_rpc_client_api::client_error::Error; + /// # use solana_rpc_client::nonblocking::rpc_client::RpcClient; /// # use solana_sdk::{ /// # signature::Signer, /// # signature::Signature, @@ -1502,9 +1494,9 @@ impl RpcClient { /// # let tx = system_transaction::transfer(&alice, &bob.pubkey(), lamports, latest_blockhash); /// let signature = rpc_client.send_transaction(&tx).await?; /// let status = rpc_client.get_signature_status(&signature).await?; - /// # Ok::<(), ClientError>(()) + /// # Ok::<(), Error>(()) /// # })?; - /// # Ok::<(), ClientError>(()) + /// # Ok::<(), Error>(()) /// ``` pub async fn get_signature_status( &self, @@ -1553,10 +1545,8 @@ impl RpcClient { /// # Examples /// /// ``` - /// # use solana_client::{ - /// # nonblocking::rpc_client::RpcClient, - /// # client_error::ClientError, - /// # }; + /// # use solana_rpc_client_api::client_error::Error; + /// # use solana_rpc_client::nonblocking::rpc_client::RpcClient; /// # use solana_sdk::{ /// # signature::Signer, /// # signature::Signature, @@ -1584,9 +1574,9 @@ impl RpcClient { /// }; /// /// assert!(status.err.is_none()); - /// # Ok::<(), ClientError>(()) + /// # Ok::<(), Error>(()) /// # })?; - /// # Ok::<(), ClientError>(()) + /// # Ok::<(), Error>(()) /// ``` pub async fn get_signature_statuses( &self, @@ -1635,10 +1625,8 @@ impl RpcClient { /// # Examples /// /// ``` - /// # use solana_client::{ - /// # nonblocking::rpc_client::RpcClient, - /// # client_error::ClientError, - /// # }; + /// # use solana_rpc_client_api::client_error::Error; + /// # use solana_rpc_client::nonblocking::rpc_client::RpcClient; /// # use solana_sdk::{ /// # signature::Signer, /// # signature::Signature, @@ -1657,9 +1645,9 @@ impl RpcClient { /// if statuses[0].is_none() { /// println!("old transaction does not exist"); /// } - /// # Ok::<(), ClientError>(()) + /// # Ok::<(), Error>(()) /// # })?; - /// # Ok::<(), ClientError>(()) + /// # Ok::<(), Error>(()) /// ``` pub async fn get_signature_statuses_with_history( &self, @@ -1708,10 +1696,8 @@ impl RpcClient { /// # Examples /// /// ``` - /// # use solana_client::{ - /// # nonblocking::rpc_client::RpcClient, - /// # client_error::ClientError, - /// # }; + /// # use solana_rpc_client_api::client_error::Error; + /// # use solana_rpc_client::nonblocking::rpc_client::RpcClient; /// # use solana_sdk::{ /// # commitment_config::CommitmentConfig, /// # signature::Signer, @@ -1732,9 +1718,9 @@ impl RpcClient { /// &signature, /// commitment_config, /// ).await?; - /// # Ok::<(), ClientError>(()) + /// # Ok::<(), Error>(()) /// # })?; - /// # Ok::<(), ClientError>(()) + /// # Ok::<(), Error>(()) /// ``` pub async fn get_signature_status_with_commitment( &self, @@ -1782,10 +1768,8 @@ impl RpcClient { /// # Examples /// /// ``` - /// # use solana_client::{ - /// # nonblocking::rpc_client::RpcClient, - /// # client_error::ClientError, - /// # }; + /// # use solana_rpc_client_api::client_error::Error; + /// # use solana_rpc_client::nonblocking::rpc_client::RpcClient; /// # use solana_sdk::{ /// # commitment_config::CommitmentConfig, /// # signature::Signer, @@ -1808,9 +1792,9 @@ impl RpcClient { /// commitment_config, /// search_transaction_history, /// ).await?; - /// # Ok::<(), ClientError>(()) + /// # Ok::<(), Error>(()) /// # })?; - /// # Ok::<(), ClientError>(()) + /// # Ok::<(), Error>(()) /// ``` pub async fn get_signature_status_with_commitment_and_history( &self, @@ -1845,16 +1829,14 @@ impl RpcClient { /// # Examples /// /// ``` - /// # use solana_client::{ - /// # nonblocking::rpc_client::RpcClient, - /// # client_error::ClientError, - /// # }; + /// # use solana_rpc_client_api::client_error::Error; + /// # use solana_rpc_client::nonblocking::rpc_client::RpcClient; /// # futures::executor::block_on(async { /// # let rpc_client = RpcClient::new_mock("succeeds".to_string()); /// let slot = rpc_client.get_slot().await?; - /// # Ok::<(), ClientError>(()) + /// # Ok::<(), Error>(()) /// # })?; - /// # Ok::<(), ClientError>(()) + /// # Ok::<(), Error>(()) /// ``` pub async fn get_slot(&self) -> ClientResult { self.get_slot_with_commitment(self.commitment()).await @@ -1873,18 +1855,16 @@ impl RpcClient { /// # Examples /// /// ``` - /// # use solana_client::{ - /// # nonblocking::rpc_client::RpcClient, - /// # client_error::ClientError, - /// # }; + /// # use solana_rpc_client_api::client_error::Error; + /// # use solana_rpc_client::nonblocking::rpc_client::RpcClient; /// # use solana_sdk::commitment_config::CommitmentConfig; /// # futures::executor::block_on(async { /// # let rpc_client = RpcClient::new_mock("succeeds".to_string()); /// let commitment_config = CommitmentConfig::processed(); /// let slot = rpc_client.get_slot_with_commitment(commitment_config).await?; - /// # Ok::<(), ClientError>(()) + /// # Ok::<(), Error>(()) /// # })?; - /// # Ok::<(), ClientError>(()) + /// # Ok::<(), Error>(()) /// ``` pub async fn get_slot_with_commitment( &self, @@ -1910,16 +1890,14 @@ impl RpcClient { /// # Examples /// /// ``` - /// # use solana_client::{ - /// # nonblocking::rpc_client::RpcClient, - /// # client_error::ClientError, - /// # }; + /// # use solana_rpc_client_api::client_error::Error; + /// # use solana_rpc_client::nonblocking::rpc_client::RpcClient; /// # futures::executor::block_on(async { /// # let rpc_client = RpcClient::new_mock("succeeds".to_string()); /// let block_height = rpc_client.get_block_height().await?; - /// # Ok::<(), ClientError>(()) + /// # Ok::<(), Error>(()) /// # })?; - /// # Ok::<(), ClientError>(()) + /// # Ok::<(), Error>(()) /// ``` pub async fn get_block_height(&self) -> ClientResult { self.get_block_height_with_commitment(self.commitment()) @@ -1939,10 +1917,8 @@ impl RpcClient { /// # Examples /// /// ``` - /// # use solana_client::{ - /// # nonblocking::rpc_client::RpcClient, - /// # client_error::ClientError, - /// # }; + /// # use solana_rpc_client_api::client_error::Error; + /// # use solana_rpc_client::nonblocking::rpc_client::RpcClient; /// # use solana_sdk::commitment_config::CommitmentConfig; /// # futures::executor::block_on(async { /// # let rpc_client = RpcClient::new_mock("succeeds".to_string()); @@ -1950,9 +1926,9 @@ impl RpcClient { /// let block_height = rpc_client.get_block_height_with_commitment( /// commitment_config, /// ).await?; - /// # Ok::<(), ClientError>(()) + /// # Ok::<(), Error>(()) /// # })?; - /// # Ok::<(), ClientError>(()) + /// # Ok::<(), Error>(()) /// ``` pub async fn get_block_height_with_commitment( &self, @@ -1976,19 +1952,17 @@ impl RpcClient { /// # Examples /// /// ``` - /// # use solana_client::{ - /// # nonblocking::rpc_client::RpcClient, - /// # client_error::ClientError, - /// # }; + /// # use solana_rpc_client_api::client_error::Error; + /// # use solana_rpc_client::nonblocking::rpc_client::RpcClient; /// # use solana_sdk::slot_history::Slot; /// # futures::executor::block_on(async { /// # let rpc_client = RpcClient::new_mock("succeeds".to_string()); /// let start_slot = 1; /// let limit = 3; /// let leaders = rpc_client.get_slot_leaders(start_slot, limit).await?; - /// # Ok::<(), ClientError>(()) + /// # Ok::<(), Error>(()) /// # })?; - /// # Ok::<(), ClientError>(()) + /// # Ok::<(), Error>(()) /// ``` pub async fn get_slot_leaders( &self, @@ -2024,16 +1998,14 @@ impl RpcClient { /// # Examples /// /// ``` - /// # use solana_client::{ - /// # nonblocking::rpc_client::RpcClient, - /// # client_error::ClientError, - /// # }; + /// # use solana_rpc_client_api::client_error::Error; + /// # use solana_rpc_client::nonblocking::rpc_client::RpcClient; /// # futures::executor::block_on(async { /// # let rpc_client = RpcClient::new_mock("succeeds".to_string()); /// let production = rpc_client.get_block_production().await?; - /// # Ok::<(), ClientError>(()) + /// # Ok::<(), Error>(()) /// # })?; - /// # Ok::<(), ClientError>(()) + /// # Ok::<(), Error>(()) /// ``` pub async fn get_block_production(&self) -> RpcResult { self.send(RpcRequest::GetBlockProduction, Value::Null).await @@ -2050,12 +2022,12 @@ impl RpcClient { /// # Examples /// /// ``` - /// # use solana_client::{ - /// # nonblocking::rpc_client::RpcClient, - /// # client_error::ClientError, - /// # rpc_config::RpcBlockProductionConfig, - /// # rpc_config::RpcBlockProductionConfigRange, + /// # use solana_rpc_client_api::{ + /// # client_error::Error, + /// # config::RpcBlockProductionConfig, + /// # config::RpcBlockProductionConfigRange, /// # }; + /// # use solana_rpc_client::nonblocking::rpc_client::RpcClient; /// # use solana_sdk::{ /// # signature::Signer, /// # signer::keypair::Keypair, @@ -2079,9 +2051,9 @@ impl RpcClient { /// let production = rpc_client.get_block_production_with_config( /// config /// ).await?; - /// # Ok::<(), ClientError>(()) + /// # Ok::<(), Error>(()) /// # })?; - /// # Ok::<(), ClientError>(()) + /// # Ok::<(), Error>(()) /// ``` pub async fn get_block_production_with_config( &self, @@ -2106,11 +2078,11 @@ impl RpcClient { /// # Examples /// /// ``` - /// # use solana_client::{ - /// # nonblocking::rpc_client::RpcClient, - /// # client_error::ClientError, - /// # rpc_response::StakeActivationState, + /// # use solana_rpc_client_api::{ + /// # client_error::Error, + /// # response::StakeActivationState, /// # }; + /// # use solana_rpc_client::nonblocking::rpc_client::RpcClient; /// # use solana_sdk::{ /// # signer::keypair::Keypair, /// # signature::Signer, @@ -2161,9 +2133,9 @@ impl RpcClient { /// ).await?; /// /// assert_eq!(activation.state, StakeActivationState::Activating); - /// # Ok::<(), ClientError>(()) + /// # Ok::<(), Error>(()) /// # })?; - /// # Ok::<(), ClientError>(()) + /// # Ok::<(), Error>(()) /// ``` pub async fn get_stake_activation( &self, @@ -2199,16 +2171,14 @@ impl RpcClient { /// # Examples /// /// ``` - /// # use solana_client::{ - /// # nonblocking::rpc_client::RpcClient, - /// # client_error::ClientError, - /// # }; + /// # use solana_rpc_client_api::client_error::Error; + /// # use solana_rpc_client::nonblocking::rpc_client::RpcClient; /// # futures::executor::block_on(async { /// # let rpc_client = RpcClient::new_mock("succeeds".to_string()); /// let supply = rpc_client.supply().await?; - /// # Ok::<(), ClientError>(()) + /// # Ok::<(), Error>(()) /// # })?; - /// # Ok::<(), ClientError>(()) + /// # Ok::<(), Error>(()) /// ``` pub async fn supply(&self) -> RpcResult { self.supply_with_commitment(self.commitment()).await @@ -2225,10 +2195,8 @@ impl RpcClient { /// # Examples /// /// ``` - /// # use solana_client::{ - /// # nonblocking::rpc_client::RpcClient, - /// # client_error::ClientError, - /// # }; + /// # use solana_rpc_client_api::client_error::Error; + /// # use solana_rpc_client::nonblocking::rpc_client::RpcClient; /// # use solana_sdk::commitment_config::CommitmentConfig; /// # futures::executor::block_on(async { /// # let rpc_client = RpcClient::new_mock("succeeds".to_string()); @@ -2236,9 +2204,9 @@ impl RpcClient { /// let supply = rpc_client.supply_with_commitment( /// commitment_config, /// ).await?; - /// # Ok::<(), ClientError>(()) + /// # Ok::<(), Error>(()) /// # })?; - /// # Ok::<(), ClientError>(()) + /// # Ok::<(), Error>(()) /// ``` pub async fn supply_with_commitment( &self, @@ -2263,12 +2231,12 @@ impl RpcClient { /// # Examples /// /// ``` - /// # use solana_client::{ - /// # nonblocking::rpc_client::RpcClient, - /// # client_error::ClientError, - /// # rpc_config::RpcLargestAccountsConfig, - /// # rpc_config::RpcLargestAccountsFilter, + /// # use solana_rpc_client_api::{ + /// # client_error::Error, + /// # config::RpcLargestAccountsConfig, + /// # config::RpcLargestAccountsFilter, /// # }; + /// # use solana_rpc_client::nonblocking::rpc_client::RpcClient; /// # use solana_sdk::commitment_config::CommitmentConfig; /// # futures::executor::block_on(async { /// # let rpc_client = RpcClient::new_mock("succeeds".to_string()); @@ -2280,9 +2248,9 @@ impl RpcClient { /// let accounts = rpc_client.get_largest_accounts_with_config( /// config, /// ).await?; - /// # Ok::<(), ClientError>(()) + /// # Ok::<(), Error>(()) /// # })?; - /// # Ok::<(), ClientError>(()) + /// # Ok::<(), Error>(()) /// ``` pub async fn get_largest_accounts_with_config( &self, @@ -2313,16 +2281,14 @@ impl RpcClient { /// # Examples /// /// ``` - /// # use solana_client::{ - /// # nonblocking::rpc_client::RpcClient, - /// # client_error::ClientError, - /// # }; + /// # use solana_rpc_client_api::client_error::Error; + /// # use solana_rpc_client::nonblocking::rpc_client::RpcClient; /// # futures::executor::block_on(async { /// # let rpc_client = RpcClient::new_mock("succeeds".to_string()); /// let accounts = rpc_client.get_vote_accounts().await?; - /// # Ok::<(), ClientError>(()) + /// # Ok::<(), Error>(()) /// # })?; - /// # Ok::<(), ClientError>(()) + /// # Ok::<(), Error>(()) /// ``` pub async fn get_vote_accounts(&self) -> ClientResult { self.get_vote_accounts_with_commitment(self.commitment()) @@ -2344,19 +2310,17 @@ impl RpcClient { /// /// ``` /// # use solana_sdk::commitment_config::CommitmentConfig; - /// # use solana_client::{ - /// # nonblocking::rpc_client::RpcClient, - /// # client_error::ClientError, - /// # }; + /// # use solana_rpc_client_api::client_error::Error; + /// # use solana_rpc_client::nonblocking::rpc_client::RpcClient; /// # futures::executor::block_on(async { /// # let rpc_client = RpcClient::new_mock("succeeds".to_string()); /// let commitment_config = CommitmentConfig::processed(); /// let accounts = rpc_client.get_vote_accounts_with_commitment( /// commitment_config, /// ).await?; - /// # Ok::<(), ClientError>(()) + /// # Ok::<(), Error>(()) /// # })?; - /// # Ok::<(), ClientError>(()) + /// # Ok::<(), Error>(()) /// ``` pub async fn get_vote_accounts_with_commitment( &self, @@ -2383,11 +2347,11 @@ impl RpcClient { /// # Examples /// /// ``` - /// # use solana_client::{ - /// # nonblocking::rpc_client::RpcClient, - /// # client_error::ClientError, - /// # rpc_config::RpcGetVoteAccountsConfig, + /// # use solana_rpc_client_api::{ + /// # client_error::Error, + /// # config::RpcGetVoteAccountsConfig, /// # }; + /// # use solana_rpc_client::nonblocking::rpc_client::RpcClient; /// # use solana_sdk::{ /// # signer::keypair::Keypair, /// # signature::Signer, @@ -2407,9 +2371,9 @@ impl RpcClient { /// let accounts = rpc_client.get_vote_accounts_with_config( /// config, /// ).await?; - /// # Ok::<(), ClientError>(()) + /// # Ok::<(), Error>(()) /// # })?; - /// # Ok::<(), ClientError>(()) + /// # Ok::<(), Error>(()) /// ``` pub async fn get_vote_accounts_with_config( &self, @@ -2463,16 +2427,14 @@ impl RpcClient { /// # Examples /// /// ``` - /// # use solana_client::{ - /// # nonblocking::rpc_client::RpcClient, - /// # client_error::ClientError, - /// # }; + /// # use solana_rpc_client_api::client_error::Error; + /// # use solana_rpc_client::nonblocking::rpc_client::RpcClient; /// # futures::executor::block_on(async { /// # let rpc_client = RpcClient::new_mock("succeeds".to_string()); /// let cluster_nodes = rpc_client.get_cluster_nodes().await?; - /// # Ok::<(), ClientError>(()) + /// # Ok::<(), Error>(()) /// # })?; - /// # Ok::<(), ClientError>(()) + /// # Ok::<(), Error>(()) /// ``` pub async fn get_cluster_nodes(&self) -> ClientResult> { self.send(RpcRequest::GetClusterNodes, Value::Null).await @@ -2497,17 +2459,15 @@ impl RpcClient { /// # Examples /// /// ``` - /// # use solana_client::{ - /// # nonblocking::rpc_client::RpcClient, - /// # client_error::ClientError, - /// # }; + /// # use solana_rpc_client_api::client_error::Error; + /// # use solana_rpc_client::nonblocking::rpc_client::RpcClient; /// # futures::executor::block_on(async { /// # let rpc_client = RpcClient::new_mock("succeeds".to_string()); /// # let slot = rpc_client.get_slot().await?; /// let block = rpc_client.get_block(slot).await?; - /// # Ok::<(), ClientError>(()) + /// # Ok::<(), Error>(()) /// # })?; - /// # Ok::<(), ClientError>(()) + /// # Ok::<(), Error>(()) /// ``` pub async fn get_block(&self, slot: Slot) -> ClientResult { self.get_block_with_encoding(slot, UiTransactionEncoding::Json) @@ -2526,10 +2486,8 @@ impl RpcClient { /// /// ``` /// # use solana_transaction_status::UiTransactionEncoding; - /// # use solana_client::{ - /// # nonblocking::rpc_client::RpcClient, - /// # client_error::ClientError, - /// # }; + /// # use solana_rpc_client_api::client_error::Error; + /// # use solana_rpc_client::nonblocking::rpc_client::RpcClient; /// # futures::executor::block_on(async { /// # let rpc_client = RpcClient::new_mock("succeeds".to_string()); /// # let slot = rpc_client.get_slot().await?; @@ -2538,9 +2496,9 @@ impl RpcClient { /// slot, /// encoding, /// ).await?; - /// # Ok::<(), ClientError>(()) + /// # Ok::<(), Error>(()) /// # })?; - /// # Ok::<(), ClientError>(()) + /// # Ok::<(), Error>(()) /// ``` pub async fn get_block_with_encoding( &self, @@ -2569,11 +2527,11 @@ impl RpcClient { /// # TransactionDetails, /// # UiTransactionEncoding, /// # }; - /// # use solana_client::{ - /// # nonblocking::rpc_client::RpcClient, - /// # rpc_config::RpcBlockConfig, - /// # client_error::ClientError, + /// # use solana_rpc_client_api::{ + /// # config::RpcBlockConfig, + /// # client_error::Error, /// # }; + /// # use solana_rpc_client::nonblocking::rpc_client::RpcClient; /// # futures::executor::block_on(async { /// # let rpc_client = RpcClient::new_mock("succeeds".to_string()); /// # let slot = rpc_client.get_slot().await?; @@ -2588,9 +2546,9 @@ impl RpcClient { /// slot, /// config, /// ).await?; - /// # Ok::<(), ClientError>(()) + /// # Ok::<(), Error>(()) /// # })?; - /// # Ok::<(), ClientError>(()) + /// # Ok::<(), Error>(()) /// ``` pub async fn get_block_with_config( &self, @@ -2673,19 +2631,17 @@ impl RpcClient { /// # Examples /// /// ``` - /// # use solana_client::{ - /// # nonblocking::rpc_client::RpcClient, - /// # client_error::ClientError, - /// # }; + /// # use solana_rpc_client_api::client_error::Error; + /// # use solana_rpc_client::nonblocking::rpc_client::RpcClient; /// # futures::executor::block_on(async { /// # let rpc_client = RpcClient::new_mock("succeeds".to_string()); /// // Get up to the first 10 blocks /// let start_slot = 0; /// let end_slot = 9; /// let blocks = rpc_client.get_blocks(start_slot, Some(end_slot)).await?; - /// # Ok::<(), ClientError>(()) + /// # Ok::<(), Error>(()) /// # })?; - /// # Ok::<(), ClientError>(()) + /// # Ok::<(), Error>(()) /// ``` pub async fn get_blocks( &self, @@ -2738,10 +2694,8 @@ impl RpcClient { /// /// ``` /// # use solana_sdk::commitment_config::CommitmentConfig; - /// # use solana_client::{ - /// # nonblocking::rpc_client::RpcClient, - /// # client_error::ClientError, - /// # }; + /// # use solana_rpc_client_api::client_error::Error; + /// # use solana_rpc_client::nonblocking::rpc_client::RpcClient; /// # futures::executor::block_on(async { /// # let rpc_client = RpcClient::new_mock("succeeds".to_string()); /// // Get up to the first 10 blocks @@ -2754,9 +2708,9 @@ impl RpcClient { /// Some(end_slot), /// commitment_config, /// ).await?; - /// # Ok::<(), ClientError>(()) + /// # Ok::<(), Error>(()) /// # })?; - /// # Ok::<(), ClientError>(()) + /// # Ok::<(), Error>(()) /// ``` pub async fn get_blocks_with_commitment( &self, @@ -2803,19 +2757,17 @@ impl RpcClient { /// # Examples /// /// ``` - /// # use solana_client::{ - /// # nonblocking::rpc_client::RpcClient, - /// # client_error::ClientError, - /// # }; + /// # use solana_rpc_client_api::client_error::Error; + /// # use solana_rpc_client::nonblocking::rpc_client::RpcClient; /// # futures::executor::block_on(async { /// # let rpc_client = RpcClient::new_mock("succeeds".to_string()); /// // Get the first 10 blocks /// let start_slot = 0; /// let limit = 10; /// let blocks = rpc_client.get_blocks_with_limit(start_slot, limit).await?; - /// # Ok::<(), ClientError>(()) + /// # Ok::<(), Error>(()) /// # })?; - /// # Ok::<(), ClientError>(()) + /// # Ok::<(), Error>(()) /// ``` pub async fn get_blocks_with_limit( &self, @@ -2855,10 +2807,8 @@ impl RpcClient { /// /// ``` /// # use solana_sdk::commitment_config::CommitmentConfig; - /// # use solana_client::{ - /// # nonblocking::rpc_client::RpcClient, - /// # client_error::ClientError, - /// # }; + /// # use solana_rpc_client_api::client_error::Error; + /// # use solana_rpc_client::nonblocking::rpc_client::RpcClient; /// # futures::executor::block_on(async { /// # let rpc_client = RpcClient::new_mock("succeeds".to_string()); /// // Get the first 10 blocks @@ -2870,9 +2820,9 @@ impl RpcClient { /// limit, /// commitment_config, /// ).await?; - /// # Ok::<(), ClientError>(()) + /// # Ok::<(), Error>(()) /// # })?; - /// # Ok::<(), ClientError>(()) + /// # Ok::<(), Error>(()) /// ``` pub async fn get_blocks_with_limit_and_commitment( &self, @@ -2992,10 +2942,8 @@ impl RpcClient { /// # Examples /// /// ``` - /// # use solana_client::{ - /// # client_error::ClientError, - /// # nonblocking::rpc_client::RpcClient, - /// # }; + /// # use solana_rpc_client_api::client_error::Error; + /// # use solana_rpc_client::nonblocking::rpc_client::RpcClient; /// # use solana_sdk::{ /// # signature::Signer, /// # signer::keypair::Keypair, @@ -3007,9 +2955,9 @@ impl RpcClient { /// let signatures = rpc_client.get_signatures_for_address( /// &alice.pubkey(), /// ).await?; - /// # Ok::<(), ClientError>(()) + /// # Ok::<(), Error>(()) /// # })?; - /// # Ok::<(), ClientError>(()) + /// # Ok::<(), Error>(()) /// ``` pub async fn get_signatures_for_address( &self, @@ -3044,8 +2992,8 @@ impl RpcClient { /// # Examples /// /// ``` - /// # use solana_client::{ - /// # client_error::ClientError, + /// # use solana_rpc_client_api::client_error::Error; + /// # use solana_rpc_client::{ /// # nonblocking::rpc_client::RpcClient, /// # rpc_client::GetConfirmedSignaturesForAddress2Config, /// # }; @@ -3073,9 +3021,9 @@ impl RpcClient { /// &alice.pubkey(), /// config, /// ).await?; - /// # Ok::<(), ClientError>(()) + /// # Ok::<(), Error>(()) /// # })?; - /// # Ok::<(), ClientError>(()) + /// # Ok::<(), Error>(()) /// ``` pub async fn get_signatures_for_address_with_config( &self, @@ -3163,10 +3111,8 @@ impl RpcClient { /// # Examples /// /// ``` - /// # use solana_client::{ - /// # client_error::ClientError, - /// # nonblocking::rpc_client::RpcClient, - /// # }; + /// # use solana_rpc_client_api::client_error::Error; + /// # use solana_rpc_client::nonblocking::rpc_client::RpcClient; /// # use solana_sdk::{ /// # signature::Signer, /// # signature::Signature, @@ -3186,9 +3132,9 @@ impl RpcClient { /// &signature, /// UiTransactionEncoding::Json, /// ).await?; - /// # Ok::<(), ClientError>(()) + /// # Ok::<(), Error>(()) /// # })?; - /// # Ok::<(), ClientError>(()) + /// # Ok::<(), Error>(()) /// ``` pub async fn get_transaction( &self, @@ -3224,11 +3170,11 @@ impl RpcClient { /// # Examples /// /// ``` - /// # use solana_client::{ - /// # client_error::ClientError, - /// # nonblocking::rpc_client::RpcClient, - /// # rpc_config::RpcTransactionConfig, + /// # use solana_rpc_client_api::{ + /// # client_error::Error, + /// # config::RpcTransactionConfig, /// # }; + /// # use solana_rpc_client::nonblocking::rpc_client::RpcClient; /// # use solana_sdk::{ /// # signature::Signer, /// # signature::Signature, @@ -3254,9 +3200,9 @@ impl RpcClient { /// &signature, /// config, /// ).await?; - /// # Ok::<(), ClientError>(()) + /// # Ok::<(), Error>(()) /// # })?; - /// # Ok::<(), ClientError>(()) + /// # Ok::<(), Error>(()) /// ``` pub async fn get_transaction_with_config( &self, @@ -3315,18 +3261,16 @@ impl RpcClient { /// # Examples /// /// ``` - /// # use solana_client::{ - /// # client_error::ClientError, - /// # nonblocking::rpc_client::RpcClient, - /// # }; + /// # use solana_rpc_client_api::client_error::Error; + /// # use solana_rpc_client::nonblocking::rpc_client::RpcClient; /// # futures::executor::block_on(async { /// # let rpc_client = RpcClient::new_mock("succeeds".to_string()); /// // Get the time of the most recent finalized block /// let slot = rpc_client.get_slot().await?; /// let block_time = rpc_client.get_block_time(slot).await?; - /// # Ok::<(), ClientError>(()) + /// # Ok::<(), Error>(()) /// # })?; - /// # Ok::<(), ClientError>(()) + /// # Ok::<(), Error>(()) /// ``` pub async fn get_block_time(&self, slot: Slot) -> ClientResult { let request = RpcRequest::GetBlockTime; @@ -3360,16 +3304,14 @@ impl RpcClient { /// # Examples /// /// ``` - /// # use solana_client::{ - /// # client_error::ClientError, - /// # nonblocking::rpc_client::RpcClient, - /// # }; + /// # use solana_rpc_client_api::client_error::Error; + /// # use solana_rpc_client::nonblocking::rpc_client::RpcClient; /// # futures::executor::block_on(async { /// # let rpc_client = RpcClient::new_mock("succeeds".to_string()); /// let epoch_info = rpc_client.get_epoch_info().await?; - /// # Ok::<(), ClientError>(()) + /// # Ok::<(), Error>(()) /// # })?; - /// # Ok::<(), ClientError>(()) + /// # Ok::<(), Error>(()) /// ``` pub async fn get_epoch_info(&self) -> ClientResult { self.get_epoch_info_with_commitment(self.commitment()).await @@ -3386,10 +3328,8 @@ impl RpcClient { /// # Examples /// /// ``` - /// # use solana_client::{ - /// # client_error::ClientError, - /// # nonblocking::rpc_client::RpcClient, - /// # }; + /// # use solana_rpc_client_api::client_error::Error; + /// # use solana_rpc_client::nonblocking::rpc_client::RpcClient; /// # use solana_sdk::commitment_config::CommitmentConfig; /// # futures::executor::block_on(async { /// # let rpc_client = RpcClient::new_mock("succeeds".to_string()); @@ -3397,9 +3337,9 @@ impl RpcClient { /// let epoch_info = rpc_client.get_epoch_info_with_commitment( /// commitment_config, /// ).await?; - /// # Ok::<(), ClientError>(()) + /// # Ok::<(), Error>(()) /// # })?; - /// # Ok::<(), ClientError>(()) + /// # Ok::<(), Error>(()) /// ``` pub async fn get_epoch_info_with_commitment( &self, @@ -3427,10 +3367,8 @@ impl RpcClient { /// # Examples /// /// ``` - /// # use solana_client::{ - /// # client_error::ClientError, - /// # nonblocking::rpc_client::RpcClient, - /// # }; + /// # use solana_rpc_client_api::client_error::Error; + /// # use solana_rpc_client::nonblocking::rpc_client::RpcClient; /// # use solana_sdk::commitment_config::CommitmentConfig; /// # futures::executor::block_on(async { /// # let rpc_client = RpcClient::new_mock("succeeds".to_string()); @@ -3438,9 +3376,9 @@ impl RpcClient { /// let leader_schedule = rpc_client.get_leader_schedule( /// Some(slot), /// ).await?; - /// # Ok::<(), ClientError>(()) + /// # Ok::<(), Error>(()) /// # })?; - /// # Ok::<(), ClientError>(()) + /// # Ok::<(), Error>(()) /// ``` pub async fn get_leader_schedule( &self, @@ -3461,10 +3399,8 @@ impl RpcClient { /// # Examples /// /// ``` - /// # use solana_client::{ - /// # client_error::ClientError, - /// # nonblocking::rpc_client::RpcClient, - /// # }; + /// # use solana_rpc_client_api::client_error::Error; + /// # use solana_rpc_client::nonblocking::rpc_client::RpcClient; /// # use solana_sdk::commitment_config::CommitmentConfig; /// # futures::executor::block_on(async { /// # let rpc_client = RpcClient::new_mock("succeeds".to_string()); @@ -3474,9 +3410,9 @@ impl RpcClient { /// Some(slot), /// commitment_config, /// ).await?; - /// # Ok::<(), ClientError>(()) + /// # Ok::<(), Error>(()) /// # })?; - /// # Ok::<(), ClientError>(()) + /// # Ok::<(), Error>(()) /// ``` pub async fn get_leader_schedule_with_commitment( &self, @@ -3504,11 +3440,11 @@ impl RpcClient { /// # Examples /// /// ``` - /// # use solana_client::{ - /// # client_error::ClientError, - /// # nonblocking::rpc_client::RpcClient, + /// # use solana_rpc_client_api::{ + /// # client_error::Error, + /// # config::RpcLeaderScheduleConfig, /// # }; - /// # use solana_client::rpc_config::RpcLeaderScheduleConfig; + /// # use solana_rpc_client::nonblocking::rpc_client::RpcClient; /// # use solana_sdk::commitment_config::CommitmentConfig; /// # futures::executor::block_on(async { /// # let rpc_client = RpcClient::new_mock("succeeds".to_string()); @@ -3522,9 +3458,9 @@ impl RpcClient { /// Some(slot), /// config, /// ).await?; - /// # Ok::<(), ClientError>(()) + /// # Ok::<(), Error>(()) /// # })?; - /// # Ok::<(), ClientError>(()) + /// # Ok::<(), Error>(()) /// ``` pub async fn get_leader_schedule_with_config( &self, @@ -3546,16 +3482,14 @@ impl RpcClient { /// # Examples /// /// ``` - /// # use solana_client::{ - /// # client_error::ClientError, - /// # nonblocking::rpc_client::RpcClient, - /// # }; + /// # use solana_rpc_client_api::client_error::Error; + /// # use solana_rpc_client::nonblocking::rpc_client::RpcClient; /// # futures::executor::block_on(async { /// # let rpc_client = RpcClient::new_mock("succeeds".to_string()); /// let epoch_schedule = rpc_client.get_epoch_schedule().await?; - /// # Ok::<(), ClientError>(()) + /// # Ok::<(), Error>(()) /// # })?; - /// # Ok::<(), ClientError>(()) + /// # Ok::<(), Error>(()) /// ``` pub async fn get_epoch_schedule(&self) -> ClientResult { self.send(RpcRequest::GetEpochSchedule, Value::Null).await @@ -3575,19 +3509,17 @@ impl RpcClient { /// # Examples /// /// ``` - /// # use solana_client::{ - /// # client_error::ClientError, - /// # nonblocking::rpc_client::RpcClient, - /// # }; + /// # use solana_rpc_client_api::client_error::Error; + /// # use solana_rpc_client::nonblocking::rpc_client::RpcClient; /// # futures::executor::block_on(async { /// # let rpc_client = RpcClient::new_mock("succeeds".to_string()); /// let limit = 10; /// let performance_samples = rpc_client.get_recent_performance_samples( /// Some(limit), /// ).await?; - /// # Ok::<(), ClientError>(()) + /// # Ok::<(), Error>(()) /// # })?; - /// # Ok::<(), ClientError>(()) + /// # Ok::<(), Error>(()) /// ``` pub async fn get_recent_performance_samples( &self, @@ -3608,16 +3540,14 @@ impl RpcClient { /// # Examples /// /// ``` - /// # use solana_client::{ - /// # client_error::ClientError, - /// # nonblocking::rpc_client::RpcClient, - /// # }; + /// # use solana_rpc_client_api::client_error::Error; + /// # use solana_rpc_client::nonblocking::rpc_client::RpcClient; /// # futures::executor::block_on(async { /// # let rpc_client = RpcClient::new_mock("succeeds".to_string()); /// let identity = rpc_client.get_identity().await?; - /// # Ok::<(), ClientError>(()) + /// # Ok::<(), Error>(()) /// # })?; - /// # Ok::<(), ClientError>(()) + /// # Ok::<(), Error>(()) /// ``` pub async fn get_identity(&self) -> ClientResult { let rpc_identity: RpcIdentity = self.send(RpcRequest::GetIdentity, Value::Null).await?; @@ -3647,16 +3577,14 @@ impl RpcClient { /// # Examples /// /// ``` - /// # use solana_client::{ - /// # client_error::ClientError, - /// # nonblocking::rpc_client::RpcClient, - /// # }; + /// # use solana_rpc_client_api::client_error::Error; + /// # use solana_rpc_client::nonblocking::rpc_client::RpcClient; /// # futures::executor::block_on(async { /// # let rpc_client = RpcClient::new_mock("succeeds".to_string()); /// let inflation_governor = rpc_client.get_inflation_governor().await?; - /// # Ok::<(), ClientError>(()) + /// # Ok::<(), Error>(()) /// # })?; - /// # Ok::<(), ClientError>(()) + /// # Ok::<(), Error>(()) /// ``` pub async fn get_inflation_governor(&self) -> ClientResult { self.send(RpcRequest::GetInflationGovernor, Value::Null) @@ -3674,16 +3602,14 @@ impl RpcClient { /// # Examples /// /// ``` - /// # use solana_client::{ - /// # client_error::ClientError, - /// # nonblocking::rpc_client::RpcClient, - /// # }; + /// # use solana_rpc_client_api::client_error::Error; + /// # use solana_rpc_client::nonblocking::rpc_client::RpcClient; /// # futures::executor::block_on(async { /// # let rpc_client = RpcClient::new_mock("succeeds".to_string()); /// let inflation_rate = rpc_client.get_inflation_rate().await?; - /// # Ok::<(), ClientError>(()) + /// # Ok::<(), Error>(()) /// # })?; - /// # Ok::<(), ClientError>(()) + /// # Ok::<(), Error>(()) /// ``` pub async fn get_inflation_rate(&self) -> ClientResult { self.send(RpcRequest::GetInflationRate, Value::Null).await @@ -3704,10 +3630,8 @@ impl RpcClient { /// # Examples /// /// ``` - /// # use solana_client::{ - /// # client_error::ClientError, - /// # nonblocking::rpc_client::RpcClient, - /// # }; + /// # use solana_rpc_client_api::client_error::Error; + /// # use solana_rpc_client::nonblocking::rpc_client::RpcClient; /// # use solana_sdk::signature::{Keypair, Signer}; /// # futures::executor::block_on(async { /// # let rpc_client = RpcClient::new_mock("succeeds".to_string()); @@ -3720,9 +3644,9 @@ impl RpcClient { /// &addresses, /// Some(epoch), /// ).await?; - /// # Ok::<(), ClientError>(()) + /// # Ok::<(), Error>(()) /// # })?; - /// # Ok::<(), ClientError>(()) + /// # Ok::<(), Error>(()) /// ``` pub async fn get_inflation_reward( &self, @@ -3758,10 +3682,8 @@ impl RpcClient { /// # Examples /// /// ``` - /// # use solana_client::{ - /// # client_error::ClientError, - /// # nonblocking::rpc_client::RpcClient, - /// # }; + /// # use solana_rpc_client_api::client_error::Error; + /// # use solana_rpc_client::nonblocking::rpc_client::RpcClient; /// # use solana_sdk::signature::{Keypair, Signer}; /// # futures::executor::block_on(async { /// # let rpc_client = RpcClient::new_mock("succeeds".to_string()); @@ -3792,16 +3714,14 @@ impl RpcClient { /// # Examples /// /// ``` - /// # use solana_client::{ - /// # client_error::ClientError, - /// # nonblocking::rpc_client::RpcClient, - /// # }; + /// # use solana_rpc_client_api::client_error::Error; + /// # use solana_rpc_client::nonblocking::rpc_client::RpcClient; /// # futures::executor::block_on(async { /// # let rpc_client = RpcClient::new_mock("succeeds".to_string()); /// let slot = rpc_client.minimum_ledger_slot().await?; - /// # Ok::<(), ClientError>(()) + /// # Ok::<(), Error>(()) /// # })?; - /// # Ok::<(), ClientError>(()) + /// # Ok::<(), Error>(()) /// ``` pub async fn minimum_ledger_slot(&self) -> ClientResult { self.send(RpcRequest::MinimumLedgerSlot, Value::Null).await @@ -3834,10 +3754,8 @@ impl RpcClient { /// # Examples /// /// ``` - /// # use solana_client::{ - /// # nonblocking::rpc_client::{self, RpcClient}, - /// # client_error::ClientError, - /// # }; + /// # use solana_rpc_client_api::client_error::Error; + /// # use solana_rpc_client::nonblocking::rpc_client::{self, RpcClient}; /// # use solana_sdk::{ /// # signature::Signer, /// # signer::keypair::Keypair, @@ -3849,9 +3767,9 @@ impl RpcClient { /// # let rpc_client = RpcClient::new_mock_with_mocks("succeeds".to_string(), mocks); /// let alice_pubkey = Pubkey::from_str("BgvYtJEfmZYdVKiptmMjxGzv8iQoo4MWjsP3QsTkhhxa").unwrap(); /// let account = rpc_client.get_account(&alice_pubkey).await?; - /// # Ok::<(), ClientError>(()) + /// # Ok::<(), Error>(()) /// # })?; - /// # Ok::<(), ClientError>(()) + /// # Ok::<(), Error>(()) /// ``` pub async fn get_account(&self, pubkey: &Pubkey) -> ClientResult { self.get_account_with_commitment(pubkey, self.commitment()) @@ -3877,10 +3795,8 @@ impl RpcClient { /// # Examples /// /// ``` - /// # use solana_client::{ - /// # nonblocking::rpc_client::{self, RpcClient}, - /// # client_error::ClientError, - /// # }; + /// # use solana_rpc_client_api::client_error::Error; + /// # use solana_rpc_client::nonblocking::rpc_client::{self, RpcClient}; /// # use solana_sdk::{ /// # signature::Signer, /// # signer::keypair::Keypair, @@ -3898,9 +3814,9 @@ impl RpcClient { /// commitment_config, /// ).await?; /// assert!(account.value.is_some()); - /// # Ok::<(), ClientError>(()) + /// # Ok::<(), Error>(()) /// # })?; - /// # Ok::<(), ClientError>(()) + /// # Ok::<(), Error>(()) /// ``` pub async fn get_account_with_commitment( &self, @@ -3934,11 +3850,11 @@ impl RpcClient { /// # Examples /// /// ``` - /// # use solana_client::{ - /// # nonblocking::rpc_client::{self, RpcClient}, - /// # rpc_config::RpcAccountInfoConfig, - /// # client_error::ClientError, + /// # use solana_rpc_client_api::{ + /// # config::RpcAccountInfoConfig, + /// # client_error::Error, /// # }; + /// # use solana_rpc_client::nonblocking::rpc_client::{self, RpcClient}; /// # use solana_sdk::{ /// # signature::Signer, /// # signer::keypair::Keypair, @@ -3962,9 +3878,9 @@ impl RpcClient { /// config, /// ).await?; /// assert!(account.value.is_some()); - /// # Ok::<(), ClientError>(()) + /// # Ok::<(), Error>(()) /// # })?; - /// # Ok::<(), ClientError>(()) + /// # Ok::<(), Error>(()) /// ``` pub async fn get_account_with_config( &self, @@ -4017,16 +3933,14 @@ impl RpcClient { /// # Examples /// /// ``` - /// # use solana_client::{ - /// # nonblocking::rpc_client::RpcClient, - /// # client_error::ClientError, - /// # }; + /// # use solana_rpc_client_api::client_error::Error; + /// # use solana_rpc_client::nonblocking::rpc_client::RpcClient; /// # futures::executor::block_on(async { /// # let rpc_client = RpcClient::new_mock("succeeds".to_string()); /// let slot = rpc_client.get_max_retransmit_slot().await?; - /// # Ok::<(), ClientError>(()) + /// # Ok::<(), Error>(()) /// # })?; - /// # Ok::<(), ClientError>(()) + /// # Ok::<(), Error>(()) pub async fn get_max_retransmit_slot(&self) -> ClientResult { self.send(RpcRequest::GetMaxRetransmitSlot, Value::Null) .await @@ -4044,16 +3958,14 @@ impl RpcClient { /// # Examples /// /// ``` - /// # use solana_client::{ - /// # nonblocking::rpc_client::RpcClient, - /// # client_error::ClientError, - /// # }; + /// # use solana_rpc_client_api::client_error::Error; + /// # use solana_rpc_client::nonblocking::rpc_client::RpcClient; /// # futures::executor::block_on(async { /// # let rpc_client = RpcClient::new_mock("succeeds".to_string()); /// let slot = rpc_client.get_max_shred_insert_slot().await?; - /// # Ok::<(), ClientError>(()) + /// # Ok::<(), Error>(()) /// # })?; - /// # Ok::<(), ClientError>(()) + /// # Ok::<(), Error>(()) pub async fn get_max_shred_insert_slot(&self) -> ClientResult { self.send(RpcRequest::GetMaxShredInsertSlot, Value::Null) .await @@ -4074,10 +3986,8 @@ impl RpcClient { /// # Examples /// /// ``` - /// # use solana_client::{ - /// # nonblocking::rpc_client::RpcClient, - /// # client_error::ClientError, - /// # }; + /// # use solana_rpc_client_api::client_error::Error; + /// # use solana_rpc_client::nonblocking::rpc_client::RpcClient; /// # use solana_sdk::{ /// # signature::Signer, /// # signer::keypair::Keypair, @@ -4088,9 +3998,9 @@ impl RpcClient { /// # let bob = Keypair::new(); /// let pubkeys = vec![alice.pubkey(), bob.pubkey()]; /// let accounts = rpc_client.get_multiple_accounts(&pubkeys).await?; - /// # Ok::<(), ClientError>(()) + /// # Ok::<(), Error>(()) /// # })?; - /// # Ok::<(), ClientError>(()) + /// # Ok::<(), Error>(()) /// ``` pub async fn get_multiple_accounts( &self, @@ -4113,10 +4023,8 @@ impl RpcClient { /// # Examples /// /// ``` - /// # use solana_client::{ - /// # nonblocking::rpc_client::RpcClient, - /// # client_error::ClientError, - /// # }; + /// # use solana_rpc_client_api::client_error::Error; + /// # use solana_rpc_client::nonblocking::rpc_client::RpcClient; /// # use solana_sdk::{ /// # signature::Signer, /// # signer::keypair::Keypair, @@ -4132,9 +4040,9 @@ impl RpcClient { /// &pubkeys, /// commitment_config, /// ).await?; - /// # Ok::<(), ClientError>(()) + /// # Ok::<(), Error>(()) /// # })?; - /// # Ok::<(), ClientError>(()) + /// # Ok::<(), Error>(()) /// ``` pub async fn get_multiple_accounts_with_commitment( &self, @@ -4164,11 +4072,11 @@ impl RpcClient { /// # Examples /// /// ``` - /// # use solana_client::{ - /// # nonblocking::rpc_client::RpcClient, - /// # rpc_config::RpcAccountInfoConfig, - /// # client_error::ClientError, + /// # use solana_rpc_client_api::{ + /// # config::RpcAccountInfoConfig, + /// # client_error::Error, /// # }; + /// # use solana_rpc_client::nonblocking::rpc_client::RpcClient; /// # use solana_sdk::{ /// # signature::Signer, /// # signer::keypair::Keypair, @@ -4190,9 +4098,9 @@ impl RpcClient { /// &pubkeys, /// config, /// ).await?; - /// # Ok::<(), ClientError>(()) + /// # Ok::<(), Error>(()) /// # })?; - /// # Ok::<(), ClientError>(()) + /// # Ok::<(), Error>(()) /// ``` pub async fn get_multiple_accounts_with_config( &self, @@ -4238,10 +4146,8 @@ impl RpcClient { /// # Examples /// /// ``` - /// # use solana_client::{ - /// # nonblocking::rpc_client::{self, RpcClient}, - /// # client_error::ClientError, - /// # }; + /// # use solana_rpc_client_api::client_error::Error; + /// # use solana_rpc_client::nonblocking::rpc_client::{self, RpcClient}; /// # use solana_sdk::{ /// # signature::Signer, /// # signer::keypair::Keypair, @@ -4253,9 +4159,9 @@ impl RpcClient { /// # let rpc_client = RpcClient::new_mock_with_mocks("succeeds".to_string(), mocks); /// let alice_pubkey = Pubkey::from_str("BgvYtJEfmZYdVKiptmMjxGzv8iQoo4MWjsP3QsTkhhxa").unwrap(); /// let account_data = rpc_client.get_account_data(&alice_pubkey).await?; - /// # Ok::<(), ClientError>(()) + /// # Ok::<(), Error>(()) /// # })?; - /// # Ok::<(), ClientError>(()) + /// # Ok::<(), Error>(()) /// ``` pub async fn get_account_data(&self, pubkey: &Pubkey) -> ClientResult> { Ok(self.get_account(pubkey).await?.data) @@ -4273,17 +4179,15 @@ impl RpcClient { /// # Examples /// /// ``` - /// # use solana_client::{ - /// # nonblocking::rpc_client::RpcClient, - /// # client_error::ClientError, - /// # }; + /// # use solana_rpc_client_api::client_error::Error; + /// # use solana_rpc_client::nonblocking::rpc_client::RpcClient; /// # futures::executor::block_on(async { /// # let rpc_client = RpcClient::new_mock("succeeds".to_string()); /// let data_len = 300; /// let balance = rpc_client.get_minimum_balance_for_rent_exemption(data_len).await?; - /// # Ok::<(), ClientError>(()) + /// # Ok::<(), Error>(()) /// # })?; - /// # Ok::<(), ClientError>(()) + /// # Ok::<(), Error>(()) /// ``` pub async fn get_minimum_balance_for_rent_exemption( &self, @@ -4320,10 +4224,8 @@ impl RpcClient { /// # Examples /// /// ``` - /// # use solana_client::{ - /// # nonblocking::rpc_client::RpcClient, - /// # client_error::ClientError, - /// # }; + /// # use solana_rpc_client_api::client_error::Error; + /// # use solana_rpc_client::nonblocking::rpc_client::RpcClient; /// # use solana_sdk::{ /// # signature::Signer, /// # signer::keypair::Keypair, @@ -4332,9 +4234,9 @@ impl RpcClient { /// # let rpc_client = RpcClient::new_mock("succeeds".to_string()); /// # let alice = Keypair::new(); /// let balance = rpc_client.get_balance(&alice.pubkey()).await?; - /// # Ok::<(), ClientError>(()) + /// # Ok::<(), Error>(()) /// # })?; - /// # Ok::<(), ClientError>(()) + /// # Ok::<(), Error>(()) /// ``` pub async fn get_balance(&self, pubkey: &Pubkey) -> ClientResult { Ok(self @@ -4354,10 +4256,8 @@ impl RpcClient { /// # Examples /// /// ``` - /// # use solana_client::{ - /// # nonblocking::rpc_client::RpcClient, - /// # client_error::ClientError, - /// # }; + /// # use solana_rpc_client_api::client_error::Error; + /// # use solana_rpc_client::nonblocking::rpc_client::RpcClient; /// # use solana_sdk::{ /// # signature::Signer, /// # signer::keypair::Keypair, @@ -4371,9 +4271,9 @@ impl RpcClient { /// &alice.pubkey(), /// commitment_config, /// ).await?; - /// # Ok::<(), ClientError>(()) + /// # Ok::<(), Error>(()) /// # })?; - /// # Ok::<(), ClientError>(()) + /// # Ok::<(), Error>(()) /// ``` pub async fn get_balance_with_commitment( &self, @@ -4406,10 +4306,8 @@ impl RpcClient { /// # Examples /// /// ``` - /// # use solana_client::{ - /// # nonblocking::rpc_client::RpcClient, - /// # client_error::ClientError, - /// # }; + /// # use solana_rpc_client_api::client_error::Error; + /// # use solana_rpc_client::nonblocking::rpc_client::RpcClient; /// # use solana_sdk::{ /// # signature::Signer, /// # signer::keypair::Keypair, @@ -4418,9 +4316,9 @@ impl RpcClient { /// # let rpc_client = RpcClient::new_mock("succeeds".to_string()); /// # let alice = Keypair::new(); /// let accounts = rpc_client.get_program_accounts(&alice.pubkey()).await?; - /// # Ok::<(), ClientError>(()) + /// # Ok::<(), Error>(()) /// # })?; - /// # Ok::<(), ClientError>(()) + /// # Ok::<(), Error>(()) /// ``` pub async fn get_program_accounts( &self, @@ -4450,12 +4348,12 @@ impl RpcClient { /// # Examples /// /// ``` - /// # use solana_client::{ - /// # nonblocking::rpc_client::RpcClient, - /// # client_error::ClientError, - /// # rpc_config::{RpcAccountInfoConfig, RpcProgramAccountsConfig}, - /// # rpc_filter::{MemcmpEncodedBytes, RpcFilterType, Memcmp}, + /// # use solana_rpc_client_api::{ + /// # client_error::Error, + /// # config::{RpcAccountInfoConfig, RpcProgramAccountsConfig}, + /// # filter::{MemcmpEncodedBytes, RpcFilterType, Memcmp}, /// # }; + /// # use solana_rpc_client::nonblocking::rpc_client::RpcClient; /// # use solana_sdk::{ /// # signature::Signer, /// # signer::keypair::Keypair, @@ -4494,9 +4392,9 @@ impl RpcClient { /// &alice.pubkey(), /// config, /// ).await?; - /// # Ok::<(), ClientError>(()) + /// # Ok::<(), Error>(()) /// # })?; - /// # Ok::<(), ClientError>(()) + /// # Ok::<(), Error>(()) /// ``` pub async fn get_program_accounts_with_config( &self, @@ -4532,16 +4430,14 @@ impl RpcClient { /// # Examples /// /// ``` - /// # use solana_client::{ - /// # nonblocking::rpc_client::RpcClient, - /// # client_error::ClientError, - /// # }; + /// # use solana_rpc_client_api::client_error::Error; + /// # use solana_rpc_client::nonblocking::rpc_client::RpcClient; /// # futures::executor::block_on(async { /// # let rpc_client = RpcClient::new_mock("succeeds".to_string()); /// let stake_minimum_delegation = rpc_client.get_stake_minimum_delegation().await?; - /// # Ok::<(), ClientError>(()) + /// # Ok::<(), Error>(()) /// # })?; - /// # Ok::<(), ClientError>(()) + /// # Ok::<(), Error>(()) /// ``` pub async fn get_stake_minimum_delegation(&self) -> ClientResult { self.get_stake_minimum_delegation_with_commitment(self.commitment()) @@ -4559,17 +4455,15 @@ impl RpcClient { /// # Examples /// /// ``` - /// # use solana_client::{ - /// # nonblocking::rpc_client::RpcClient, - /// # client_error::ClientError, - /// # }; + /// # use solana_rpc_client_api::client_error::Error; + /// # use solana_rpc_client::nonblocking::rpc_client::RpcClient; /// # use solana_sdk::commitment_config::CommitmentConfig; /// # futures::executor::block_on(async { /// # let rpc_client = RpcClient::new_mock("succeeds".to_string()); /// let stake_minimum_delegation = rpc_client.get_stake_minimum_delegation_with_commitment(CommitmentConfig::confirmed()).await?; - /// # Ok::<(), ClientError>(()) + /// # Ok::<(), Error>(()) /// # })?; - /// # Ok::<(), ClientError>(()) + /// # Ok::<(), Error>(()) /// ``` pub async fn get_stake_minimum_delegation_with_commitment( &self, diff --git a/client/src/rpc_client.rs b/rpc-client/src/rpc_client.rs similarity index 90% rename from client/src/rpc_client.rs rename to rpc-client/src/rpc_client.rs index c387fe6e74..d90f2d4cc8 100644 --- a/client/src/rpc_client.rs +++ b/rpc-client/src/rpc_client.rs @@ -8,16 +8,14 @@ pub use crate::mock_sender::Mocks; #[allow(deprecated)] -use crate::rpc_deprecated_config::{RpcConfirmedBlockConfig, RpcConfirmedTransactionConfig}; +use solana_rpc_client_api::deprecated_config::{ + RpcConfirmedBlockConfig, RpcConfirmedTransactionConfig, +}; use { crate::{ - client_error::Result as ClientResult, http_sender::HttpSender, mock_sender::MockSender, nonblocking::{self, rpc_client::get_rpc_request_str}, - rpc_config::{RpcAccountInfoConfig, *}, - rpc_request::{RpcRequest, TokenAccountsFilter}, - rpc_response::*, rpc_sender::*, }, serde_json::Value, @@ -25,6 +23,12 @@ use { parse_token::{UiTokenAccount, UiTokenAmount}, UiAccount, UiAccountEncoding, }, + solana_rpc_client_api::{ + client_error::Result as ClientResult, + config::{RpcAccountInfoConfig, *}, + request::{RpcRequest, TokenAccountsFilter}, + response::*, + }, solana_sdk::{ account::Account, clock::{Epoch, Slot, UnixTimestamp}, @@ -114,19 +118,19 @@ pub struct GetConfirmedSignaturesForAddress2Config { /// # Errors /// /// Methods on `RpcClient` return -/// [`client_error::Result`][crate::client_error::Result], and many of them -/// return the [`RpcResult`][crate::rpc_response::RpcResult] typedef, which -/// contains [`Response`][crate::rpc_response::Response] on `Ok`. Both +/// [`client_error::Result`][solana_rpc_client_api::client_error::Result], and many of them +/// return the [`RpcResult`][solana_rpc_client_api::response::RpcResult] typedef, which +/// contains [`Response`][solana_rpc_client_api::response::Response] on `Ok`. Both /// `client_error::Result` and [`RpcResult`] contain `ClientError` on error. In /// the case of `RpcResult`, the actual return value is in the -/// [`value`][crate::rpc_response::Response::value] field, with RPC contextual -/// information in the [`context`][crate::rpc_response::Response::context] +/// [`value`][solana_rpc_client_api::response::Response::value] field, with RPC contextual +/// information in the [`context`][solana_rpc_client_api::response::Response::context] /// field, so it is common for the value to be accessed with `?.value`, as in /// /// ``` /// # use solana_sdk::system_transaction; -/// # use solana_client::rpc_client::RpcClient; -/// # use solana_client::client_error::ClientError; +/// # use solana_rpc_client_api::client_error::Error; +/// # use solana_rpc_client::rpc_client::RpcClient; /// # use solana_sdk::signature::{Keypair, Signer}; /// # use solana_sdk::hash::Hash; /// # let rpc_client = RpcClient::new_mock("succeeds".to_string()); @@ -137,19 +141,19 @@ pub struct GetConfirmedSignaturesForAddress2Config { /// # let tx = system_transaction::transfer(&key, &to, lamports, latest_blockhash); /// let signature = rpc_client.send_transaction(&tx)?; /// let statuses = rpc_client.get_signature_statuses(&[signature])?.value; -/// # Ok::<(), ClientError>(()) +/// # Ok::<(), Error>(()) /// ``` /// /// Requests may timeout, in which case they return a [`ClientError`] where the /// [`ClientErrorKind`] is [`ClientErrorKind::Reqwest`], and where the interior -/// [`reqwest::Error`](crate::client_error::reqwest::Error)s -/// [`is_timeout`](crate::client_error::reqwest::Error::is_timeout) method +/// [`reqwest::Error`](solana_rpc_client_api::client_error::reqwest::Error)s +/// [`is_timeout`](solana_rpc_client_api::client_error::reqwest::Error::is_timeout) method /// returns `true`. The default timeout is 30 seconds, and may be changed by /// calling an appropriate constructor with a `timeout` parameter. /// -/// [`ClientError`]: crate::client_error::ClientError -/// [`ClientErrorKind`]: crate::client_error::ClientErrorKind -/// [`ClientErrorKind::Reqwest`]: crate::client_error::ClientErrorKind::Reqwest +/// [`ClientError`]: solana_rpc_client_api::client_error::Error +/// [`ClientErrorKind`]: solana_rpc_client_api::client_error::ErrorKind +/// [`ClientErrorKind::Reqwest`]: solana_rpc_client_api::client_error::ErrorKind::Reqwest pub struct RpcClient { rpc_client: Arc, runtime: Option, @@ -201,7 +205,7 @@ impl RpcClient { /// # Examples /// /// ``` - /// # use solana_client::rpc_client::RpcClient; + /// # use solana_rpc_client::rpc_client::RpcClient; /// let url = "http://localhost:8899".to_string(); /// let client = RpcClient::new(url); /// ``` @@ -225,7 +229,7 @@ impl RpcClient { /// /// ``` /// # use solana_sdk::commitment_config::CommitmentConfig; - /// # use solana_client::rpc_client::RpcClient; + /// # use solana_rpc_client::rpc_client::RpcClient; /// let url = "http://localhost:8899".to_string(); /// let commitment_config = CommitmentConfig::processed(); /// let client = RpcClient::new_with_commitment(url, commitment_config); @@ -252,7 +256,7 @@ impl RpcClient { /// /// ``` /// # use std::time::Duration; - /// # use solana_client::rpc_client::RpcClient; + /// # use solana_rpc_client::rpc_client::RpcClient; /// let url = "http://localhost::8899".to_string(); /// let timeout = Duration::from_secs(1); /// let client = RpcClient::new_with_timeout(url, timeout); @@ -275,7 +279,7 @@ impl RpcClient { /// /// ``` /// # use std::time::Duration; - /// # use solana_client::rpc_client::RpcClient; + /// # use solana_rpc_client::rpc_client::RpcClient; /// # use solana_sdk::commitment_config::CommitmentConfig; /// let url = "http://localhost::8899".to_string(); /// let timeout = Duration::from_secs(1); @@ -316,7 +320,7 @@ impl RpcClient { /// /// ``` /// # use std::time::Duration; - /// # use solana_client::rpc_client::RpcClient; + /// # use solana_rpc_client::rpc_client::RpcClient; /// # use solana_sdk::commitment_config::CommitmentConfig; /// let url = "http://localhost::8899".to_string(); /// let timeout = Duration::from_secs(1); @@ -378,14 +382,14 @@ impl RpcClient { /// # Examples /// /// ``` - /// # use solana_client::rpc_client::RpcClient; + /// # use solana_rpc_client::rpc_client::RpcClient; /// // Create an `RpcClient` that always succeeds /// let url = "succeeds".to_string(); /// let successful_client = RpcClient::new_mock(url); /// ``` /// /// ``` - /// # use solana_client::rpc_client::RpcClient; + /// # use solana_rpc_client::rpc_client::RpcClient; /// // Create an `RpcClient` that always fails /// let url = "fails".to_string(); /// let successful_client = RpcClient::new_mock(url); @@ -440,11 +444,11 @@ impl RpcClient { /// # Examples /// /// ``` - /// # use solana_client::{ - /// # rpc_client::RpcClient, - /// # rpc_request::RpcRequest, - /// # rpc_response::{Response, RpcResponseContext}, + /// # use solana_rpc_client_api::{ + /// # request::RpcRequest, + /// # response::{Response, RpcResponseContext}, /// # }; + /// # use solana_rpc_client::rpc_client::RpcClient; /// # use std::collections::HashMap; /// # use serde_json::json; /// // Create a mock with a custom repsonse to the `GetBalance` request @@ -478,7 +482,7 @@ impl RpcClient { /// /// ``` /// # use std::net::SocketAddr; - /// # use solana_client::rpc_client::RpcClient; + /// # use solana_rpc_client::rpc_client::RpcClient; /// let addr = SocketAddr::from(([127, 0, 0, 1], 8899)); /// let client = RpcClient::new_socket(addr); /// ``` @@ -499,7 +503,7 @@ impl RpcClient { /// /// ``` /// # use std::net::SocketAddr; - /// # use solana_client::rpc_client::RpcClient; + /// # use solana_rpc_client::rpc_client::RpcClient; /// # use solana_sdk::commitment_config::CommitmentConfig; /// let addr = SocketAddr::from(([127, 0, 0, 1], 8899)); /// let commitment_config = CommitmentConfig::processed(); @@ -527,7 +531,7 @@ impl RpcClient { /// ``` /// # use std::net::SocketAddr; /// # use std::time::Duration; - /// # use solana_client::rpc_client::RpcClient; + /// # use solana_rpc_client::rpc_client::RpcClient; /// let addr = SocketAddr::from(([127, 0, 0, 1], 8899)); /// let timeout = Duration::from_secs(1); /// let client = RpcClient::new_socket_with_timeout(addr, timeout); @@ -586,11 +590,11 @@ impl RpcClient { /// containing an [`RpcResponseError`] with `code` set to /// [`JSON_RPC_SERVER_ERROR_NODE_UNHEALTHY`]. /// - /// [`RpcError`]: crate::rpc_request::RpcError - /// [`RpcResponseError`]: crate::rpc_request::RpcError::RpcResponseError - /// [`JSON_RPC_SERVER_ERROR_TRANSACTION_SIGNATURE_VERIFICATION_FAILURE`]: crate::rpc_custom_error::JSON_RPC_SERVER_ERROR_TRANSACTION_SIGNATURE_VERIFICATION_FAILURE - /// [`JSON_RPC_SERVER_ERROR_SEND_TRANSACTION_PREFLIGHT_FAILURE`]: crate::rpc_custom_error::JSON_RPC_SERVER_ERROR_SEND_TRANSACTION_PREFLIGHT_FAILURE - /// [`JSON_RPC_SERVER_ERROR_NODE_UNHEALTHY`]: crate::rpc_custom_error::JSON_RPC_SERVER_ERROR_NODE_UNHEALTHY + /// [`RpcError`]: solana_rpc_client_api::request::RpcError + /// [`RpcResponseError`]: solana_rpc_client_api::request::RpcError::RpcResponseError + /// [`JSON_RPC_SERVER_ERROR_TRANSACTION_SIGNATURE_VERIFICATION_FAILURE`]: solana_rpc_client_api::custom_error::JSON_RPC_SERVER_ERROR_TRANSACTION_SIGNATURE_VERIFICATION_FAILURE + /// [`JSON_RPC_SERVER_ERROR_SEND_TRANSACTION_PREFLIGHT_FAILURE`]: solana_rpc_client_api::custom_error::JSON_RPC_SERVER_ERROR_SEND_TRANSACTION_PREFLIGHT_FAILURE + /// [`JSON_RPC_SERVER_ERROR_NODE_UNHEALTHY`]: solana_rpc_client_api::custom_error::JSON_RPC_SERVER_ERROR_NODE_UNHEALTHY /// /// # RPC Reference /// @@ -603,10 +607,8 @@ impl RpcClient { /// # Examples /// /// ``` - /// # use solana_client::{ - /// # rpc_client::RpcClient, - /// # client_error::ClientError, - /// # }; + /// # use solana_rpc_client_api::client_error::Error; + /// # use solana_rpc_client::rpc_client::RpcClient; /// # use solana_sdk::{ /// # signature::Signer, /// # signature::Signature, @@ -620,7 +622,7 @@ impl RpcClient { /// # let latest_blockhash = rpc_client.get_latest_blockhash()?; /// let tx = system_transaction::transfer(&alice, &bob.pubkey(), lamports, latest_blockhash); /// let signature = rpc_client.send_and_confirm_transaction(&tx)?; - /// # Ok::<(), ClientError>(()) + /// # Ok::<(), Error>(()) /// ``` pub fn send_and_confirm_transaction( &self, @@ -679,8 +681,8 @@ impl RpcClient { /// method. /// /// [`send_transaction_with_config`]: RpcClient::send_transaction_with_config - /// [`skip_preflight`]: crate::rpc_config::RpcSendTransactionConfig::skip_preflight - /// [`RpcSendTransactionConfig`]: crate::rpc_config::RpcSendTransactionConfig + /// [`skip_preflight`]: solana_rpc_client_api::config::RpcSendTransactionConfig::skip_preflight + /// [`RpcSendTransactionConfig`]: solana_rpc_client_api::config::RpcSendTransactionConfig /// [`send_and_confirm_transaction`]: RpcClient::send_and_confirm_transaction /// /// # Errors @@ -698,11 +700,11 @@ impl RpcClient { /// containing an [`RpcResponseError`] with `code` set to /// [`JSON_RPC_SERVER_ERROR_NODE_UNHEALTHY`]. /// - /// [`RpcError`]: crate::rpc_request::RpcError - /// [`RpcResponseError`]: crate::rpc_request::RpcError::RpcResponseError - /// [`JSON_RPC_SERVER_ERROR_TRANSACTION_SIGNATURE_VERIFICATION_FAILURE`]: crate::rpc_custom_error::JSON_RPC_SERVER_ERROR_TRANSACTION_SIGNATURE_VERIFICATION_FAILURE - /// [`JSON_RPC_SERVER_ERROR_SEND_TRANSACTION_PREFLIGHT_FAILURE`]: crate::rpc_custom_error::JSON_RPC_SERVER_ERROR_SEND_TRANSACTION_PREFLIGHT_FAILURE - /// [`JSON_RPC_SERVER_ERROR_NODE_UNHEALTHY`]: crate::rpc_custom_error::JSON_RPC_SERVER_ERROR_NODE_UNHEALTHY + /// [`RpcError`]: solana_rpc_client_api::request::RpcError + /// [`RpcResponseError`]: solana_rpc_client_api::request::RpcError::RpcResponseError + /// [`JSON_RPC_SERVER_ERROR_TRANSACTION_SIGNATURE_VERIFICATION_FAILURE`]: solana_rpc_client_api::custom_error::JSON_RPC_SERVER_ERROR_TRANSACTION_SIGNATURE_VERIFICATION_FAILURE + /// [`JSON_RPC_SERVER_ERROR_SEND_TRANSACTION_PREFLIGHT_FAILURE`]: solana_rpc_client_api::custom_error::JSON_RPC_SERVER_ERROR_SEND_TRANSACTION_PREFLIGHT_FAILURE + /// [`JSON_RPC_SERVER_ERROR_NODE_UNHEALTHY`]: solana_rpc_client_api::custom_error::JSON_RPC_SERVER_ERROR_NODE_UNHEALTHY /// /// # RPC Reference /// @@ -713,10 +715,8 @@ impl RpcClient { /// # Examples /// /// ``` - /// # use solana_client::{ - /// # client_error::ClientError, - /// # rpc_client::RpcClient, - /// # }; + /// # use solana_rpc_client_api::client_error::Error; + /// # use solana_rpc_client::rpc_client::RpcClient; /// # use solana_sdk::{ /// # signature::Signer, /// # signature::Signature, @@ -732,7 +732,7 @@ impl RpcClient { /// let latest_blockhash = rpc_client.get_latest_blockhash()?; /// let tx = system_transaction::transfer(&alice, &bob.pubkey(), lamports, latest_blockhash); /// let signature = rpc_client.send_transaction(&tx)?; - /// # Ok::<(), ClientError>(()) + /// # Ok::<(), Error>(()) /// ``` pub fn send_transaction(&self, transaction: &Transaction) -> ClientResult { self.invoke((self.rpc_client.as_ref()).send_transaction(transaction)) @@ -752,8 +752,8 @@ impl RpcClient { /// method. /// /// [`send_transaction_with_config`]: RpcClient::send_transaction_with_config - /// [`skip_preflight`]: crate::rpc_config::RpcSendTransactionConfig::skip_preflight - /// [`RpcSendTransactionConfig`]: crate::rpc_config::RpcSendTransactionConfig + /// [`skip_preflight`]: solana_rpc_client_api::config::RpcSendTransactionConfig::skip_preflight + /// [`RpcSendTransactionConfig`]: solana_rpc_client_api::config::RpcSendTransactionConfig /// [`send_and_confirm_transaction`]: RpcClient::send_and_confirm_transaction /// /// # Errors @@ -773,11 +773,11 @@ impl RpcClient { /// containing an [`RpcResponseError`] with `code` set to /// [`JSON_RPC_SERVER_ERROR_NODE_UNHEALTHY`]. /// - /// [`RpcError`]: crate::rpc_request::RpcError - /// [`RpcResponseError`]: crate::rpc_request::RpcError::RpcResponseError - /// [`JSON_RPC_SERVER_ERROR_TRANSACTION_SIGNATURE_VERIFICATION_FAILURE`]: crate::rpc_custom_error::JSON_RPC_SERVER_ERROR_TRANSACTION_SIGNATURE_VERIFICATION_FAILURE - /// [`JSON_RPC_SERVER_ERROR_SEND_TRANSACTION_PREFLIGHT_FAILURE`]: crate::rpc_custom_error::JSON_RPC_SERVER_ERROR_SEND_TRANSACTION_PREFLIGHT_FAILURE - /// [`JSON_RPC_SERVER_ERROR_NODE_UNHEALTHY`]: crate::rpc_custom_error::JSON_RPC_SERVER_ERROR_NODE_UNHEALTHY + /// [`RpcError`]: solana_rpc_client_api::request::RpcError + /// [`RpcResponseError`]: solana_rpc_client_api::request::RpcError::RpcResponseError + /// [`JSON_RPC_SERVER_ERROR_TRANSACTION_SIGNATURE_VERIFICATION_FAILURE`]: solana_rpc_client_api::custom_error::JSON_RPC_SERVER_ERROR_TRANSACTION_SIGNATURE_VERIFICATION_FAILURE + /// [`JSON_RPC_SERVER_ERROR_SEND_TRANSACTION_PREFLIGHT_FAILURE`]: solana_rpc_client_api::custom_error::JSON_RPC_SERVER_ERROR_SEND_TRANSACTION_PREFLIGHT_FAILURE + /// [`JSON_RPC_SERVER_ERROR_NODE_UNHEALTHY`]: solana_rpc_client_api::custom_error::JSON_RPC_SERVER_ERROR_NODE_UNHEALTHY /// /// # RPC Reference /// @@ -788,11 +788,11 @@ impl RpcClient { /// # Examples /// /// ``` - /// # use solana_client::{ - /// # client_error::ClientError, - /// # rpc_client::RpcClient, - /// # rpc_config::RpcSendTransactionConfig, + /// # use solana_rpc_client_api::{ + /// # client_error::Error, + /// # config::RpcSendTransactionConfig, /// # }; + /// # use solana_rpc_client::rpc_client::RpcClient; /// # use solana_sdk::{ /// # signature::Signer, /// # signature::Signature, @@ -815,7 +815,7 @@ impl RpcClient { /// &tx, /// config, /// )?; - /// # Ok::<(), ClientError>(()) + /// # Ok::<(), Error>(()) /// ``` pub fn send_transaction_with_config( &self, @@ -857,10 +857,8 @@ impl RpcClient { /// # Examples /// /// ``` - /// # use solana_client::{ - /// # client_error::ClientError, - /// # rpc_client::RpcClient, - /// # }; + /// # use solana_rpc_client_api::client_error::Error; + /// # use solana_rpc_client::rpc_client::RpcClient; /// # use solana_sdk::{ /// # signature::Signer, /// # signature::Signature, @@ -882,7 +880,7 @@ impl RpcClient { /// break; /// } /// } - /// # Ok::<(), ClientError>(()) + /// # Ok::<(), Error>(()) /// ``` pub fn confirm_transaction(&self, signature: &Signature) -> ClientResult { self.invoke((self.rpc_client.as_ref()).confirm_transaction(signature)) @@ -912,10 +910,8 @@ impl RpcClient { /// # Examples /// /// ``` - /// # use solana_client::{ - /// # client_error::ClientError, - /// # rpc_client::RpcClient, - /// # }; + /// # use solana_rpc_client_api::client_error::Error; + /// # use solana_rpc_client::rpc_client::RpcClient; /// # use solana_sdk::{ /// # commitment_config::CommitmentConfig, /// # signature::Signer, @@ -940,7 +936,7 @@ impl RpcClient { /// break; /// } /// } - /// # Ok::<(), ClientError>(()) + /// # Ok::<(), Error>(()) /// ``` pub fn confirm_transaction_with_commitment( &self, @@ -972,8 +968,8 @@ impl RpcClient { /// [`RpcSimulateTransactionResult`] will be `Some`. Any logs emitted from /// the transaction are returned in the [`logs`] field. /// - /// [`err`]: crate::rpc_response::RpcSimulateTransactionResult::err - /// [`logs`]: crate::rpc_response::RpcSimulateTransactionResult::logs + /// [`err`]: solana_rpc_client_api::response::RpcSimulateTransactionResult::err + /// [`logs`]: solana_rpc_client_api::response::RpcSimulateTransactionResult::logs /// /// Simulating a transaction is similar to the ["preflight check"] that is /// run by default when sending a transaction. @@ -986,7 +982,7 @@ impl RpcClient { /// `true`. /// /// [`simulate_transaction_with_config`]: RpcClient::simulate_transaction_with_config - /// [`sig_verify`]: crate::rpc_config::RpcSimulateTransactionConfig::sig_verify + /// [`sig_verify`]: solana_rpc_client_api::config::RpcSimulateTransactionConfig::sig_verify /// /// # RPC Reference /// @@ -997,11 +993,11 @@ impl RpcClient { /// # Examples /// /// ``` - /// # use solana_client::{ - /// # client_error::ClientError, - /// # rpc_client::RpcClient, - /// # rpc_response::RpcSimulateTransactionResult, + /// # use solana_rpc_client_api::{ + /// # client_error::Error, + /// # response::RpcSimulateTransactionResult, /// # }; + /// # use solana_rpc_client::rpc_client::RpcClient; /// # use solana_sdk::{ /// # signature::Signer, /// # signature::Signature, @@ -1018,7 +1014,7 @@ impl RpcClient { /// let tx = system_transaction::transfer(&alice, &bob.pubkey(), lamports, latest_blockhash); /// let result = rpc_client.simulate_transaction(&tx)?; /// assert!(result.value.err.is_none()); - /// # Ok::<(), ClientError>(()) + /// # Ok::<(), Error>(()) /// ``` pub fn simulate_transaction( &self, @@ -1033,8 +1029,8 @@ impl RpcClient { /// [`RpcSimulateTransactionResult`] will be `Some`. Any logs emitted from /// the transaction are returned in the [`logs`] field. /// - /// [`err`]: crate::rpc_response::RpcSimulateTransactionResult::err - /// [`logs`]: crate::rpc_response::RpcSimulateTransactionResult::logs + /// [`err`]: solana_rpc_client_api::response::RpcSimulateTransactionResult::err + /// [`logs`]: solana_rpc_client_api::response::RpcSimulateTransactionResult::logs /// /// Simulating a transaction is similar to the ["preflight check"] that is /// run by default when sending a transaction. @@ -1047,7 +1043,7 @@ impl RpcClient { /// `true`. /// /// [`simulate_transaction_with_config`]: RpcClient::simulate_transaction_with_config - /// [`sig_verify`]: crate::rpc_config::RpcSimulateTransactionConfig::sig_verify + /// [`sig_verify`]: solana_rpc_client_api::config::RpcSimulateTransactionConfig::sig_verify /// /// This method can additionally query information about accounts by /// including them in the [`accounts`] field of the @@ -1055,8 +1051,8 @@ impl RpcClient { /// are reported in the [`accounts`][accounts2] field of the returned /// [`RpcSimulateTransactionResult`]. /// - /// [`accounts`]: crate::rpc_config::RpcSimulateTransactionConfig::accounts - /// [accounts2]: crate::rpc_response::RpcSimulateTransactionResult::accounts + /// [`accounts`]: solana_rpc_client_api::config::RpcSimulateTransactionConfig::accounts + /// [accounts2]: solana_rpc_client_api::response::RpcSimulateTransactionResult::accounts /// /// # RPC Reference /// @@ -1067,12 +1063,12 @@ impl RpcClient { /// # Examples /// /// ``` - /// # use solana_client::{ - /// # client_error::ClientError, - /// # rpc_client::RpcClient, - /// # rpc_config::RpcSimulateTransactionConfig, - /// # rpc_response::RpcSimulateTransactionResult, + /// # use solana_rpc_client_api::{ + /// # client_error::Error, + /// # config::RpcSimulateTransactionConfig, + /// # response::RpcSimulateTransactionResult, /// # }; + /// # use solana_rpc_client::rpc_client::RpcClient; /// # use solana_sdk::{ /// # signature::Signer, /// # signer::keypair::Keypair, @@ -1095,7 +1091,7 @@ impl RpcClient { /// config, /// )?; /// assert!(result.value.err.is_none()); - /// # Ok::<(), ClientError>(()) + /// # Ok::<(), Error>(()) /// ``` pub fn simulate_transaction_with_config( &self, @@ -1121,13 +1117,11 @@ impl RpcClient { /// # Examples /// /// ``` - /// # use solana_client::{ - /// # rpc_client::RpcClient, - /// # client_error::ClientError, - /// # }; + /// # use solana_rpc_client_api::client_error::Error; + /// # use solana_rpc_client::rpc_client::RpcClient; /// # let rpc_client = RpcClient::new_mock("succeeds".to_string()); /// let snapshot_slot_info = rpc_client.get_highest_snapshot_slot()?; - /// # Ok::<(), ClientError>(()) + /// # Ok::<(), Error>(()) /// ``` pub fn get_highest_snapshot_slot(&self) -> ClientResult { self.invoke((self.rpc_client.as_ref()).get_highest_snapshot_slot()) @@ -1175,10 +1169,8 @@ impl RpcClient { /// # Examples /// /// ``` - /// # use solana_client::{ - /// # rpc_client::RpcClient, - /// # client_error::ClientError, - /// # }; + /// # use solana_rpc_client_api::client_error::Error; + /// # use solana_rpc_client::rpc_client::RpcClient; /// # use solana_sdk::{ /// # signature::Signer, /// # signature::Signature, @@ -1194,7 +1186,7 @@ impl RpcClient { /// # let tx = system_transaction::transfer(&alice, &bob.pubkey(), lamports, latest_blockhash); /// let signature = rpc_client.send_transaction(&tx)?; /// let status = rpc_client.get_signature_status(&signature)?; - /// # Ok::<(), ClientError>(()) + /// # Ok::<(), Error>(()) /// ``` pub fn get_signature_status( &self, @@ -1242,10 +1234,8 @@ impl RpcClient { /// # Examples /// /// ``` - /// # use solana_client::{ - /// # rpc_client::RpcClient, - /// # client_error::ClientError, - /// # }; + /// # use solana_rpc_client_api::client_error::Error; + /// # use solana_rpc_client::rpc_client::RpcClient; /// # use solana_sdk::{ /// # signature::Signer, /// # signature::Signature, @@ -1272,7 +1262,7 @@ impl RpcClient { /// }; /// /// assert!(status.err.is_none()); - /// # Ok::<(), ClientError>(()) + /// # Ok::<(), Error>(()) /// ``` pub fn get_signature_statuses( &self, @@ -1319,10 +1309,8 @@ impl RpcClient { /// # Examples /// /// ``` - /// # use solana_client::{ - /// # rpc_client::RpcClient, - /// # client_error::ClientError, - /// # }; + /// # use solana_rpc_client_api::client_error::Error; + /// # use solana_rpc_client::rpc_client::RpcClient; /// # use solana_sdk::{ /// # signature::Signer, /// # signature::Signature, @@ -1340,7 +1328,7 @@ impl RpcClient { /// if statuses[0].is_none() { /// println!("old transaction does not exist"); /// } - /// # Ok::<(), ClientError>(()) + /// # Ok::<(), Error>(()) /// ``` pub fn get_signature_statuses_with_history( &self, @@ -1382,10 +1370,8 @@ impl RpcClient { /// # Examples /// /// ``` - /// # use solana_client::{ - /// # rpc_client::RpcClient, - /// # client_error::ClientError, - /// # }; + /// # use solana_rpc_client_api::client_error::Error; + /// # use solana_rpc_client::rpc_client::RpcClient; /// # use solana_sdk::{ /// # commitment_config::CommitmentConfig, /// # signature::Signer, @@ -1405,7 +1391,7 @@ impl RpcClient { /// &signature, /// commitment_config, /// )?; - /// # Ok::<(), ClientError>(()) + /// # Ok::<(), Error>(()) /// ``` pub fn get_signature_status_with_commitment( &self, @@ -1447,10 +1433,8 @@ impl RpcClient { /// # Examples /// /// ``` - /// # use solana_client::{ - /// # rpc_client::RpcClient, - /// # client_error::ClientError, - /// # }; + /// # use solana_rpc_client_api::client_error::Error; + /// # use solana_rpc_client::rpc_client::RpcClient; /// # use solana_sdk::{ /// # commitment_config::CommitmentConfig, /// # signature::Signer, @@ -1472,7 +1456,7 @@ impl RpcClient { /// commitment_config, /// search_transaction_history, /// )?; - /// # Ok::<(), ClientError>(()) + /// # Ok::<(), Error>(()) /// ``` pub fn get_signature_status_with_commitment_and_history( &self, @@ -1502,13 +1486,11 @@ impl RpcClient { /// # Examples /// /// ``` - /// # use solana_client::{ - /// # rpc_client::RpcClient, - /// # client_error::ClientError, - /// # }; + /// # use solana_rpc_client_api::client_error::Error; + /// # use solana_rpc_client::rpc_client::RpcClient; /// # let rpc_client = RpcClient::new_mock("succeeds".to_string()); /// let slot = rpc_client.get_slot()?; - /// # Ok::<(), ClientError>(()) + /// # Ok::<(), Error>(()) /// ``` pub fn get_slot(&self) -> ClientResult { self.invoke((self.rpc_client.as_ref()).get_slot()) @@ -1527,15 +1509,13 @@ impl RpcClient { /// # Examples /// /// ``` - /// # use solana_client::{ - /// # rpc_client::RpcClient, - /// # client_error::ClientError, - /// # }; + /// # use solana_rpc_client_api::client_error::Error; + /// # use solana_rpc_client::rpc_client::RpcClient; /// # use solana_sdk::commitment_config::CommitmentConfig; /// # let rpc_client = RpcClient::new_mock("succeeds".to_string()); /// let commitment_config = CommitmentConfig::processed(); /// let slot = rpc_client.get_slot_with_commitment(commitment_config)?; - /// # Ok::<(), ClientError>(()) + /// # Ok::<(), Error>(()) /// ``` pub fn get_slot_with_commitment( &self, @@ -1557,13 +1537,11 @@ impl RpcClient { /// # Examples /// /// ``` - /// # use solana_client::{ - /// # rpc_client::RpcClient, - /// # client_error::ClientError, - /// # }; + /// # use solana_rpc_client_api::client_error::Error; + /// # use solana_rpc_client::rpc_client::RpcClient; /// # let rpc_client = RpcClient::new_mock("succeeds".to_string()); /// let block_height = rpc_client.get_block_height()?; - /// # Ok::<(), ClientError>(()) + /// # Ok::<(), Error>(()) /// ``` pub fn get_block_height(&self) -> ClientResult { self.invoke((self.rpc_client.as_ref()).get_block_height()) @@ -1582,17 +1560,15 @@ impl RpcClient { /// # Examples /// /// ``` - /// # use solana_client::{ - /// # rpc_client::RpcClient, - /// # client_error::ClientError, - /// # }; + /// # use solana_rpc_client_api::client_error::Error; + /// # use solana_rpc_client::rpc_client::RpcClient; /// # use solana_sdk::commitment_config::CommitmentConfig; /// # let rpc_client = RpcClient::new_mock("succeeds".to_string()); /// let commitment_config = CommitmentConfig::processed(); /// let block_height = rpc_client.get_block_height_with_commitment( /// commitment_config, /// )?; - /// # Ok::<(), ClientError>(()) + /// # Ok::<(), Error>(()) /// ``` pub fn get_block_height_with_commitment( &self, @@ -1612,16 +1588,14 @@ impl RpcClient { /// # Examples /// /// ``` - /// # use solana_client::{ - /// # rpc_client::RpcClient, - /// # client_error::ClientError, - /// # }; + /// # use solana_rpc_client_api::client_error::Error; + /// # use solana_rpc_client::rpc_client::RpcClient; /// # use solana_sdk::slot_history::Slot; /// # let rpc_client = RpcClient::new_mock("succeeds".to_string()); /// let start_slot = 1; /// let limit = 3; /// let leaders = rpc_client.get_slot_leaders(start_slot, limit)?; - /// # Ok::<(), ClientError>(()) + /// # Ok::<(), Error>(()) /// ``` pub fn get_slot_leaders(&self, start_slot: Slot, limit: u64) -> ClientResult> { self.invoke((self.rpc_client.as_ref()).get_slot_leaders(start_slot, limit)) @@ -1638,13 +1612,11 @@ impl RpcClient { /// # Examples /// /// ``` - /// # use solana_client::{ - /// # rpc_client::RpcClient, - /// # client_error::ClientError, - /// # }; + /// # use solana_rpc_client_api::client_error::Error; + /// # use solana_rpc_client::rpc_client::RpcClient; /// # let rpc_client = RpcClient::new_mock("succeeds".to_string()); /// let production = rpc_client.get_block_production()?; - /// # Ok::<(), ClientError>(()) + /// # Ok::<(), Error>(()) /// ``` pub fn get_block_production(&self) -> RpcResult { self.invoke((self.rpc_client.as_ref()).get_block_production()) @@ -1661,12 +1633,11 @@ impl RpcClient { /// # Examples /// /// ``` - /// # use solana_client::{ - /// # rpc_client::RpcClient, - /// # client_error::ClientError, - /// # rpc_config::RpcBlockProductionConfig, - /// # rpc_config::RpcBlockProductionConfigRange, + /// # use solana_rpc_client_api::{ + /// # client_error::Error, + /// # config::{RpcBlockProductionConfig, RpcBlockProductionConfigRange}, /// # }; + /// # use solana_rpc_client::rpc_client::RpcClient; /// # use solana_sdk::{ /// # signature::Signer, /// # signer::keypair::Keypair, @@ -1689,7 +1660,7 @@ impl RpcClient { /// let production = rpc_client.get_block_production_with_config( /// config /// )?; - /// # Ok::<(), ClientError>(()) + /// # Ok::<(), Error>(()) /// ``` pub fn get_block_production_with_config( &self, @@ -1713,11 +1684,11 @@ impl RpcClient { /// # Examples /// /// ``` - /// # use solana_client::{ - /// # rpc_client::RpcClient, - /// # client_error::ClientError, - /// # rpc_response::StakeActivationState, + /// # use solana_rpc_client_api::{ + /// # client_error::Error, + /// # response::StakeActivationState, /// # }; + /// # use solana_rpc_client::rpc_client::RpcClient; /// # use solana_sdk::{ /// # signer::keypair::Keypair, /// # signature::Signer, @@ -1767,7 +1738,7 @@ impl RpcClient { /// )?; /// /// assert_eq!(activation.state, StakeActivationState::Activating); - /// # Ok::<(), ClientError>(()) + /// # Ok::<(), Error>(()) /// ``` pub fn get_stake_activation( &self, @@ -1792,13 +1763,11 @@ impl RpcClient { /// # Examples /// /// ``` - /// # use solana_client::{ - /// # rpc_client::RpcClient, - /// # client_error::ClientError, - /// # }; + /// # use solana_rpc_client_api::client_error::Error; + /// # use solana_rpc_client::rpc_client::RpcClient; /// # let rpc_client = RpcClient::new_mock("succeeds".to_string()); /// let supply = rpc_client.supply()?; - /// # Ok::<(), ClientError>(()) + /// # Ok::<(), Error>(()) /// ``` pub fn supply(&self) -> RpcResult { self.invoke((self.rpc_client.as_ref()).supply()) @@ -1815,17 +1784,15 @@ impl RpcClient { /// # Examples /// /// ``` - /// # use solana_client::{ - /// # rpc_client::RpcClient, - /// # client_error::ClientError, - /// # }; + /// # use solana_rpc_client_api::client_error::Error; + /// # use solana_rpc_client::rpc_client::RpcClient; /// # use solana_sdk::commitment_config::CommitmentConfig; /// # let rpc_client = RpcClient::new_mock("succeeds".to_string()); /// let commitment_config = CommitmentConfig::processed(); /// let supply = rpc_client.supply_with_commitment( /// commitment_config, /// )?; - /// # Ok::<(), ClientError>(()) + /// # Ok::<(), Error>(()) /// ``` pub fn supply_with_commitment( &self, @@ -1846,12 +1813,11 @@ impl RpcClient { /// # Examples /// /// ``` - /// # use solana_client::{ - /// # rpc_client::RpcClient, - /// # client_error::ClientError, - /// # rpc_config::RpcLargestAccountsConfig, - /// # rpc_config::RpcLargestAccountsFilter, + /// # use solana_rpc_client_api::{ + /// # client_error::Error, + /// # config::{RpcLargestAccountsConfig, RpcLargestAccountsFilter}, /// # }; + /// # use solana_rpc_client::rpc_client::RpcClient; /// # use solana_sdk::commitment_config::CommitmentConfig; /// # let rpc_client = RpcClient::new_mock("succeeds".to_string()); /// let commitment_config = CommitmentConfig::processed(); @@ -1862,7 +1828,7 @@ impl RpcClient { /// let accounts = rpc_client.get_largest_accounts_with_config( /// config, /// )?; - /// # Ok::<(), ClientError>(()) + /// # Ok::<(), Error>(()) /// ``` pub fn get_largest_accounts_with_config( &self, @@ -1886,13 +1852,11 @@ impl RpcClient { /// # Examples /// /// ``` - /// # use solana_client::{ - /// # rpc_client::RpcClient, - /// # client_error::ClientError, - /// # }; + /// # use solana_rpc_client_api::client_error::Error; + /// # use solana_rpc_client::rpc_client::RpcClient; /// # let rpc_client = RpcClient::new_mock("succeeds".to_string()); /// let accounts = rpc_client.get_vote_accounts()?; - /// # Ok::<(), ClientError>(()) + /// # Ok::<(), Error>(()) /// ``` pub fn get_vote_accounts(&self) -> ClientResult { self.invoke((self.rpc_client.as_ref()).get_vote_accounts()) @@ -1912,17 +1876,15 @@ impl RpcClient { /// # Examples /// /// ``` + /// # use solana_rpc_client_api::client_error::Error; + /// # use solana_rpc_client::rpc_client::RpcClient; /// # use solana_sdk::commitment_config::CommitmentConfig; - /// # use solana_client::{ - /// # rpc_client::RpcClient, - /// # client_error::ClientError, - /// # }; /// # let rpc_client = RpcClient::new_mock("succeeds".to_string()); /// let commitment_config = CommitmentConfig::processed(); /// let accounts = rpc_client.get_vote_accounts_with_commitment( /// commitment_config, /// )?; - /// # Ok::<(), ClientError>(()) + /// # Ok::<(), Error>(()) /// ``` pub fn get_vote_accounts_with_commitment( &self, @@ -1945,11 +1907,11 @@ impl RpcClient { /// # Examples /// /// ``` - /// # use solana_client::{ - /// # rpc_client::RpcClient, - /// # client_error::ClientError, - /// # rpc_config::RpcGetVoteAccountsConfig, + /// # use solana_rpc_client_api::{ + /// # client_error::Error, + /// # config::RpcGetVoteAccountsConfig, /// # }; + /// # use solana_rpc_client::rpc_client::RpcClient; /// # use solana_sdk::{ /// # signer::keypair::Keypair, /// # signature::Signer, @@ -1968,7 +1930,7 @@ impl RpcClient { /// let accounts = rpc_client.get_vote_accounts_with_config( /// config, /// )?; - /// # Ok::<(), ClientError>(()) + /// # Ok::<(), Error>(()) /// ``` pub fn get_vote_accounts_with_config( &self, @@ -1997,13 +1959,11 @@ impl RpcClient { /// # Examples /// /// ``` - /// # use solana_client::{ - /// # rpc_client::RpcClient, - /// # client_error::ClientError, - /// # }; + /// # use solana_rpc_client_api::client_error::Error; + /// # use solana_rpc_client::rpc_client::RpcClient; /// # let rpc_client = RpcClient::new_mock("succeeds".to_string()); /// let cluster_nodes = rpc_client.get_cluster_nodes()?; - /// # Ok::<(), ClientError>(()) + /// # Ok::<(), Error>(()) /// ``` pub fn get_cluster_nodes(&self) -> ClientResult> { self.invoke((self.rpc_client.as_ref()).get_cluster_nodes()) @@ -2028,14 +1988,12 @@ impl RpcClient { /// # Examples /// /// ``` - /// # use solana_client::{ - /// # rpc_client::RpcClient, - /// # client_error::ClientError, - /// # }; + /// # use solana_rpc_client_api::client_error::Error; + /// # use solana_rpc_client::rpc_client::RpcClient; /// # let rpc_client = RpcClient::new_mock("succeeds".to_string()); /// # let slot = rpc_client.get_slot()?; /// let block = rpc_client.get_block(slot)?; - /// # Ok::<(), ClientError>(()) + /// # Ok::<(), Error>(()) /// ``` pub fn get_block(&self, slot: Slot) -> ClientResult { self.invoke((self.rpc_client.as_ref()).get_block(slot)) @@ -2052,11 +2010,9 @@ impl RpcClient { /// # Examples /// /// ``` + /// # use solana_rpc_client_api::client_error::Error; + /// # use solana_rpc_client::rpc_client::RpcClient; /// # use solana_transaction_status::UiTransactionEncoding; - /// # use solana_client::{ - /// # rpc_client::RpcClient, - /// # client_error::ClientError, - /// # }; /// # let rpc_client = RpcClient::new_mock("succeeds".to_string()); /// # let slot = rpc_client.get_slot()?; /// let encoding = UiTransactionEncoding::Base58; @@ -2064,7 +2020,7 @@ impl RpcClient { /// slot, /// encoding, /// )?; - /// # Ok::<(), ClientError>(()) + /// # Ok::<(), Error>(()) /// ``` pub fn get_block_with_encoding( &self, @@ -2085,15 +2041,15 @@ impl RpcClient { /// # Examples /// /// ``` + /// # use solana_rpc_client_api::{ + /// # config::RpcBlockConfig, + /// # client_error::Error, + /// # }; + /// # use solana_rpc_client::rpc_client::RpcClient; /// # use solana_transaction_status::{ /// # TransactionDetails, /// # UiTransactionEncoding, /// # }; - /// # use solana_client::{ - /// # rpc_client::RpcClient, - /// # rpc_config::RpcBlockConfig, - /// # client_error::ClientError, - /// # }; /// # let rpc_client = RpcClient::new_mock("succeeds".to_string()); /// # let slot = rpc_client.get_slot()?; /// let config = RpcBlockConfig { @@ -2107,7 +2063,7 @@ impl RpcClient { /// slot, /// config, /// )?; - /// # Ok::<(), ClientError>(()) + /// # Ok::<(), Error>(()) /// ``` pub fn get_block_with_config( &self, @@ -2183,16 +2139,14 @@ impl RpcClient { /// # Examples /// /// ``` - /// # use solana_client::{ - /// # rpc_client::RpcClient, - /// # client_error::ClientError, - /// # }; + /// # use solana_rpc_client_api::client_error::Error; + /// # use solana_rpc_client::rpc_client::RpcClient; /// # let rpc_client = RpcClient::new_mock("succeeds".to_string()); /// // Get up to the first 10 blocks /// let start_slot = 0; /// let end_slot = 9; /// let blocks = rpc_client.get_blocks(start_slot, Some(end_slot))?; - /// # Ok::<(), ClientError>(()) + /// # Ok::<(), Error>(()) /// ``` pub fn get_blocks(&self, start_slot: Slot, end_slot: Option) -> ClientResult> { self.invoke((self.rpc_client.as_ref()).get_blocks(start_slot, end_slot)) @@ -2236,11 +2190,9 @@ impl RpcClient { /// # Examples /// /// ``` + /// # use solana_rpc_client_api::client_error::Error; + /// # use solana_rpc_client::rpc_client::RpcClient; /// # use solana_sdk::commitment_config::CommitmentConfig; - /// # use solana_client::{ - /// # rpc_client::RpcClient, - /// # client_error::ClientError, - /// # }; /// # let rpc_client = RpcClient::new_mock("succeeds".to_string()); /// // Get up to the first 10 blocks /// let start_slot = 0; @@ -2252,7 +2204,7 @@ impl RpcClient { /// Some(end_slot), /// commitment_config, /// )?; - /// # Ok::<(), ClientError>(()) + /// # Ok::<(), Error>(()) /// ``` pub fn get_blocks_with_commitment( &self, @@ -2290,16 +2242,14 @@ impl RpcClient { /// # Examples /// /// ``` - /// # use solana_client::{ - /// # rpc_client::RpcClient, - /// # client_error::ClientError, - /// # }; + /// # use solana_rpc_client_api::client_error::Error; + /// # use solana_rpc_client::rpc_client::RpcClient; /// # let rpc_client = RpcClient::new_mock("succeeds".to_string()); /// // Get the first 10 blocks /// let start_slot = 0; /// let limit = 10; /// let blocks = rpc_client.get_blocks_with_limit(start_slot, limit)?; - /// # Ok::<(), ClientError>(()) + /// # Ok::<(), Error>(()) /// ``` pub fn get_blocks_with_limit(&self, start_slot: Slot, limit: usize) -> ClientResult> { self.invoke((self.rpc_client.as_ref()).get_blocks_with_limit(start_slot, limit)) @@ -2329,11 +2279,9 @@ impl RpcClient { /// # Examples /// /// ``` + /// # use solana_rpc_client_api::client_error::Error; + /// # use solana_rpc_client::rpc_client::RpcClient; /// # use solana_sdk::commitment_config::CommitmentConfig; - /// # use solana_client::{ - /// # rpc_client::RpcClient, - /// # client_error::ClientError, - /// # }; /// # let rpc_client = RpcClient::new_mock("succeeds".to_string()); /// // Get the first 10 blocks /// let start_slot = 0; @@ -2344,7 +2292,7 @@ impl RpcClient { /// limit, /// commitment_config, /// )?; - /// # Ok::<(), ClientError>(()) + /// # Ok::<(), Error>(()) /// ``` pub fn get_blocks_with_limit_and_commitment( &self, @@ -2445,10 +2393,8 @@ impl RpcClient { /// # Examples /// /// ``` - /// # use solana_client::{ - /// # client_error::ClientError, - /// # rpc_client::RpcClient, - /// # }; + /// # use solana_rpc_client_api::client_error::Error; + /// # use solana_rpc_client::rpc_client::RpcClient; /// # use solana_sdk::{ /// # signature::Signer, /// # signer::keypair::Keypair, @@ -2459,7 +2405,7 @@ impl RpcClient { /// let signatures = rpc_client.get_signatures_for_address( /// &alice.pubkey(), /// )?; - /// # Ok::<(), ClientError>(()) + /// # Ok::<(), Error>(()) /// ``` pub fn get_signatures_for_address( &self, @@ -2490,11 +2436,8 @@ impl RpcClient { /// # Examples /// /// ``` - /// # use solana_client::{ - /// # client_error::ClientError, - /// # rpc_client::RpcClient, - /// # rpc_client::GetConfirmedSignaturesForAddress2Config, - /// # }; + /// # use solana_rpc_client_api::client_error::Error; + /// # use solana_rpc_client::rpc_client::{GetConfirmedSignaturesForAddress2Config, RpcClient}; /// # use solana_sdk::{ /// # signature::Signer, /// # signer::keypair::Keypair, @@ -2518,7 +2461,7 @@ impl RpcClient { /// &alice.pubkey(), /// config, /// )?; - /// # Ok::<(), ClientError>(()) + /// # Ok::<(), Error>(()) /// ``` pub fn get_signatures_for_address_with_config( &self, @@ -2577,10 +2520,8 @@ impl RpcClient { /// # Examples /// /// ``` - /// # use solana_client::{ - /// # client_error::ClientError, - /// # rpc_client::RpcClient, - /// # }; + /// # use solana_rpc_client_api::client_error::Error; + /// # use solana_rpc_client::rpc_client::RpcClient; /// # use solana_sdk::{ /// # signature::Signer, /// # signature::Signature, @@ -2599,7 +2540,7 @@ impl RpcClient { /// &signature, /// UiTransactionEncoding::Json, /// )?; - /// # Ok::<(), ClientError>(()) + /// # Ok::<(), Error>(()) /// ``` pub fn get_transaction( &self, @@ -2631,11 +2572,11 @@ impl RpcClient { /// # Examples /// /// ``` - /// # use solana_client::{ - /// # client_error::ClientError, - /// # rpc_client::RpcClient, - /// # rpc_config::RpcTransactionConfig, + /// # use solana_rpc_client_api::{ + /// # client_error::Error, + /// # config::RpcTransactionConfig, /// # }; + /// # use solana_rpc_client::rpc_client::RpcClient; /// # use solana_sdk::{ /// # signature::Signer, /// # signature::Signature, @@ -2660,7 +2601,7 @@ impl RpcClient { /// &signature, /// config, /// )?; - /// # Ok::<(), ClientError>(()) + /// # Ok::<(), Error>(()) /// ``` pub fn get_transaction_with_config( &self, @@ -2709,15 +2650,13 @@ impl RpcClient { /// # Examples /// /// ``` - /// # use solana_client::{ - /// # client_error::ClientError, - /// # rpc_client::RpcClient, - /// # }; + /// # use solana_rpc_client_api::client_error::Error; + /// # use solana_rpc_client::rpc_client::RpcClient; /// # let rpc_client = RpcClient::new_mock("succeeds".to_string()); /// // Get the time of the most recent finalized block /// let slot = rpc_client.get_slot()?; /// let block_time = rpc_client.get_block_time(slot)?; - /// # Ok::<(), ClientError>(()) + /// # Ok::<(), Error>(()) /// ``` pub fn get_block_time(&self, slot: Slot) -> ClientResult { self.invoke((self.rpc_client.as_ref()).get_block_time(slot)) @@ -2738,13 +2677,11 @@ impl RpcClient { /// # Examples /// /// ``` - /// # use solana_client::{ - /// # client_error::ClientError, - /// # rpc_client::RpcClient, - /// # }; + /// # use solana_rpc_client_api::client_error::Error; + /// # use solana_rpc_client::rpc_client::RpcClient; /// # let rpc_client = RpcClient::new_mock("succeeds".to_string()); /// let epoch_info = rpc_client.get_epoch_info()?; - /// # Ok::<(), ClientError>(()) + /// # Ok::<(), Error>(()) /// ``` pub fn get_epoch_info(&self) -> ClientResult { self.invoke((self.rpc_client.as_ref()).get_epoch_info()) @@ -2761,17 +2698,15 @@ impl RpcClient { /// # Examples /// /// ``` - /// # use solana_client::{ - /// # client_error::ClientError, - /// # rpc_client::RpcClient, - /// # }; + /// # use solana_rpc_client_api::client_error::Error; + /// # use solana_rpc_client::rpc_client::RpcClient; /// # use solana_sdk::commitment_config::CommitmentConfig; /// # let rpc_client = RpcClient::new_mock("succeeds".to_string()); /// let commitment_config = CommitmentConfig::confirmed(); /// let epoch_info = rpc_client.get_epoch_info_with_commitment( /// commitment_config, /// )?; - /// # Ok::<(), ClientError>(()) + /// # Ok::<(), Error>(()) /// ``` pub fn get_epoch_info_with_commitment( &self, @@ -2795,17 +2730,15 @@ impl RpcClient { /// # Examples /// /// ``` - /// # use solana_client::{ - /// # client_error::ClientError, - /// # rpc_client::RpcClient, - /// # }; + /// # use solana_rpc_client_api::client_error::Error; + /// # use solana_rpc_client::rpc_client::RpcClient; /// # use solana_sdk::commitment_config::CommitmentConfig; /// # let rpc_client = RpcClient::new_mock("succeeds".to_string()); /// # let slot = rpc_client.get_slot()?; /// let leader_schedule = rpc_client.get_leader_schedule( /// Some(slot), /// )?; - /// # Ok::<(), ClientError>(()) + /// # Ok::<(), Error>(()) /// ``` pub fn get_leader_schedule( &self, @@ -2825,10 +2758,8 @@ impl RpcClient { /// # Examples /// /// ``` - /// # use solana_client::{ - /// # client_error::ClientError, - /// # rpc_client::RpcClient, - /// # }; + /// # use solana_rpc_client_api::client_error::Error; + /// # use solana_rpc_client::rpc_client::RpcClient; /// # use solana_sdk::commitment_config::CommitmentConfig; /// # let rpc_client = RpcClient::new_mock("succeeds".to_string()); /// # let slot = rpc_client.get_slot()?; @@ -2837,7 +2768,7 @@ impl RpcClient { /// Some(slot), /// commitment_config, /// )?; - /// # Ok::<(), ClientError>(()) + /// # Ok::<(), Error>(()) /// ``` pub fn get_leader_schedule_with_commitment( &self, @@ -2860,11 +2791,11 @@ impl RpcClient { /// # Examples /// /// ``` - /// # use solana_client::{ - /// # client_error::ClientError, - /// # rpc_client::RpcClient, + /// # use solana_rpc_client_api::{ + /// # client_error::Error, + /// # config::RpcLeaderScheduleConfig, /// # }; - /// # use solana_client::rpc_config::RpcLeaderScheduleConfig; + /// # use solana_rpc_client::rpc_client::RpcClient; /// # use solana_sdk::commitment_config::CommitmentConfig; /// # let rpc_client = RpcClient::new_mock("succeeds".to_string()); /// # let slot = rpc_client.get_slot()?; @@ -2877,7 +2808,7 @@ impl RpcClient { /// Some(slot), /// config, /// )?; - /// # Ok::<(), ClientError>(()) + /// # Ok::<(), Error>(()) /// ``` pub fn get_leader_schedule_with_config( &self, @@ -2898,13 +2829,11 @@ impl RpcClient { /// # Examples /// /// ``` - /// # use solana_client::{ - /// # client_error::ClientError, - /// # rpc_client::RpcClient, - /// # }; + /// # use solana_rpc_client_api::client_error::Error; + /// # use solana_rpc_client::rpc_client::RpcClient; /// # let rpc_client = RpcClient::new_mock("succeeds".to_string()); /// let epoch_schedule = rpc_client.get_epoch_schedule()?; - /// # Ok::<(), ClientError>(()) + /// # Ok::<(), Error>(()) /// ``` pub fn get_epoch_schedule(&self) -> ClientResult { self.invoke((self.rpc_client.as_ref()).get_epoch_schedule()) @@ -2924,16 +2853,14 @@ impl RpcClient { /// # Examples /// /// ``` - /// # use solana_client::{ - /// # client_error::ClientError, - /// # rpc_client::RpcClient, - /// # }; + /// # use solana_rpc_client_api::client_error::Error; + /// # use solana_rpc_client::rpc_client::RpcClient; /// # let rpc_client = RpcClient::new_mock("succeeds".to_string()); /// let limit = 10; /// let performance_samples = rpc_client.get_recent_performance_samples( /// Some(limit), /// )?; - /// # Ok::<(), ClientError>(()) + /// # Ok::<(), Error>(()) /// ``` pub fn get_recent_performance_samples( &self, @@ -2953,13 +2880,11 @@ impl RpcClient { /// # Examples /// /// ``` - /// # use solana_client::{ - /// # client_error::ClientError, - /// # rpc_client::RpcClient, - /// # }; + /// # use solana_rpc_client_api::client_error::Error; + /// # use solana_rpc_client::rpc_client::RpcClient; /// # let rpc_client = RpcClient::new_mock("succeeds".to_string()); /// let identity = rpc_client.get_identity()?; - /// # Ok::<(), ClientError>(()) + /// # Ok::<(), Error>(()) /// ``` pub fn get_identity(&self) -> ClientResult { self.invoke((self.rpc_client.as_ref()).get_identity()) @@ -2982,13 +2907,11 @@ impl RpcClient { /// # Examples /// /// ``` - /// # use solana_client::{ - /// # client_error::ClientError, - /// # rpc_client::RpcClient, - /// # }; + /// # use solana_rpc_client_api::client_error::Error; + /// # use solana_rpc_client::rpc_client::RpcClient; /// # let rpc_client = RpcClient::new_mock("succeeds".to_string()); /// let inflation_governor = rpc_client.get_inflation_governor()?; - /// # Ok::<(), ClientError>(()) + /// # Ok::<(), Error>(()) /// ``` pub fn get_inflation_governor(&self) -> ClientResult { self.invoke((self.rpc_client.as_ref()).get_inflation_governor()) @@ -3005,13 +2928,11 @@ impl RpcClient { /// # Examples /// /// ``` - /// # use solana_client::{ - /// # client_error::ClientError, - /// # rpc_client::RpcClient, - /// # }; + /// # use solana_rpc_client_api::client_error::Error; + /// # use solana_rpc_client::rpc_client::RpcClient; /// # let rpc_client = RpcClient::new_mock("succeeds".to_string()); /// let inflation_rate = rpc_client.get_inflation_rate()?; - /// # Ok::<(), ClientError>(()) + /// # Ok::<(), Error>(()) /// ``` pub fn get_inflation_rate(&self) -> ClientResult { self.invoke((self.rpc_client.as_ref()).get_inflation_rate()) @@ -3032,10 +2953,8 @@ impl RpcClient { /// # Examples /// /// ``` - /// # use solana_client::{ - /// # client_error::ClientError, - /// # rpc_client::RpcClient, - /// # }; + /// # use solana_rpc_client_api::client_error::Error; + /// # use solana_rpc_client::rpc_client::RpcClient; /// # use solana_sdk::signature::{Keypair, Signer}; /// # let rpc_client = RpcClient::new_mock("succeeds".to_string()); /// # let epoch_info = rpc_client.get_epoch_info()?; @@ -3047,7 +2966,7 @@ impl RpcClient { /// &addresses, /// Some(epoch), /// )?; - /// # Ok::<(), ClientError>(()) + /// # Ok::<(), Error>(()) /// ``` pub fn get_inflation_reward( &self, @@ -3068,10 +2987,8 @@ impl RpcClient { /// # Examples /// /// ``` - /// # use solana_client::{ - /// # client_error::ClientError, - /// # rpc_client::RpcClient, - /// # }; + /// # use solana_rpc_client_api::client_error::Error; + /// # use solana_rpc_client::rpc_client::RpcClient; /// # use solana_sdk::signature::{Keypair, Signer}; /// # let rpc_client = RpcClient::new_mock("succeeds".to_string()); /// let expected_version = semver::Version::new(1, 7, 0); @@ -3099,13 +3016,11 @@ impl RpcClient { /// # Examples /// /// ``` - /// # use solana_client::{ - /// # client_error::ClientError, - /// # rpc_client::RpcClient, - /// # }; + /// # use solana_rpc_client_api::client_error::Error; + /// # use solana_rpc_client::rpc_client::RpcClient; /// # let rpc_client = RpcClient::new_mock("succeeds".to_string()); /// let slot = rpc_client.minimum_ledger_slot()?; - /// # Ok::<(), ClientError>(()) + /// # Ok::<(), Error>(()) /// ``` pub fn minimum_ledger_slot(&self) -> ClientResult { self.invoke((self.rpc_client.as_ref()).minimum_ledger_slot()) @@ -3127,7 +3042,7 @@ impl RpcClient { /// [`RpcError::ForUser`]. This is unlike [`get_account_with_commitment`], /// which returns `Ok(None)` if the account does not exist. /// - /// [`RpcError::ForUser`]: crate::rpc_request::RpcError::ForUser + /// [`RpcError::ForUser`]: solana_rpc_client_api::request::RpcError::ForUser /// [`get_account_with_commitment`]: RpcClient::get_account_with_commitment /// /// # RPC Reference @@ -3139,10 +3054,8 @@ impl RpcClient { /// # Examples /// /// ``` - /// # use solana_client::{ - /// # rpc_client::{self, RpcClient}, - /// # client_error::ClientError, - /// # }; + /// # use solana_rpc_client_api::client_error::Error; + /// # use solana_rpc_client::rpc_client::{self, RpcClient}; /// # use solana_sdk::{ /// # signature::Signer, /// # signer::keypair::Keypair, @@ -3153,7 +3066,7 @@ impl RpcClient { /// # let rpc_client = RpcClient::new_mock_with_mocks("succeeds".to_string(), mocks); /// let alice_pubkey = Pubkey::from_str("BgvYtJEfmZYdVKiptmMjxGzv8iQoo4MWjsP3QsTkhhxa").unwrap(); /// let account = rpc_client.get_account(&alice_pubkey)?; - /// # Ok::<(), ClientError>(()) + /// # Ok::<(), Error>(()) /// ``` pub fn get_account(&self, pubkey: &Pubkey) -> ClientResult { self.invoke((self.rpc_client.as_ref()).get_account(pubkey)) @@ -3176,10 +3089,8 @@ impl RpcClient { /// # Examples /// /// ``` - /// # use solana_client::{ - /// # rpc_client::{self, RpcClient}, - /// # client_error::ClientError, - /// # }; + /// # use solana_rpc_client_api::client_error::Error; + /// # use solana_rpc_client::rpc_client::{self, RpcClient}; /// # use solana_sdk::{ /// # signature::Signer, /// # signer::keypair::Keypair, @@ -3196,7 +3107,7 @@ impl RpcClient { /// commitment_config, /// )?; /// assert!(account.value.is_some()); - /// # Ok::<(), ClientError>(()) + /// # Ok::<(), Error>(()) /// ``` pub fn get_account_with_commitment( &self, @@ -3225,11 +3136,11 @@ impl RpcClient { /// # Examples /// /// ``` - /// # use solana_client::{ - /// # rpc_client::{self, RpcClient}, - /// # rpc_config::RpcAccountInfoConfig, - /// # client_error::ClientError, + /// # use solana_rpc_client_api::{ + /// # config::RpcAccountInfoConfig, + /// # client_error::Error, /// # }; + /// # use solana_rpc_client::rpc_client::{self, RpcClient}; /// # use solana_sdk::{ /// # signature::Signer, /// # signer::keypair::Keypair, @@ -3252,7 +3163,7 @@ impl RpcClient { /// config, /// )?; /// assert!(account.value.is_some()); - /// # Ok::<(), ClientError>(()) + /// # Ok::<(), Error>(()) /// ``` pub fn get_account_with_config( &self, @@ -3274,13 +3185,11 @@ impl RpcClient { /// # Examples /// /// ``` - /// # use solana_client::{ - /// # rpc_client::RpcClient, - /// # client_error::ClientError, - /// # }; + /// # use solana_rpc_client_api::client_error::Error; + /// # use solana_rpc_client::rpc_client::RpcClient; /// # let rpc_client = RpcClient::new_mock("succeeds".to_string()); /// let slot = rpc_client.get_max_retransmit_slot()?; - /// # Ok::<(), ClientError>(()) + /// # Ok::<(), Error>(()) pub fn get_max_retransmit_slot(&self) -> ClientResult { self.invoke((self.rpc_client.as_ref()).get_max_retransmit_slot()) } @@ -3297,13 +3206,11 @@ impl RpcClient { /// # Examples /// /// ``` - /// # use solana_client::{ - /// # rpc_client::RpcClient, - /// # client_error::ClientError, - /// # }; + /// # use solana_rpc_client_api::client_error::Error; + /// # use solana_rpc_client::rpc_client::RpcClient; /// # let rpc_client = RpcClient::new_mock("succeeds".to_string()); /// let slot = rpc_client.get_max_shred_insert_slot()?; - /// # Ok::<(), ClientError>(()) + /// # Ok::<(), Error>(()) pub fn get_max_shred_insert_slot(&self) -> ClientResult { self.invoke((self.rpc_client.as_ref()).get_max_shred_insert_slot()) } @@ -3323,10 +3230,8 @@ impl RpcClient { /// # Examples /// /// ``` - /// # use solana_client::{ - /// # rpc_client::RpcClient, - /// # client_error::ClientError, - /// # }; + /// # use solana_rpc_client_api::client_error::Error; + /// # use solana_rpc_client::rpc_client::RpcClient; /// # use solana_sdk::{ /// # signature::Signer, /// # signer::keypair::Keypair, @@ -3336,7 +3241,7 @@ impl RpcClient { /// # let bob = Keypair::new(); /// let pubkeys = vec![alice.pubkey(), bob.pubkey()]; /// let accounts = rpc_client.get_multiple_accounts(&pubkeys)?; - /// # Ok::<(), ClientError>(()) + /// # Ok::<(), Error>(()) /// ``` pub fn get_multiple_accounts(&self, pubkeys: &[Pubkey]) -> ClientResult>> { self.invoke((self.rpc_client.as_ref()).get_multiple_accounts(pubkeys)) @@ -3353,10 +3258,8 @@ impl RpcClient { /// # Examples /// /// ``` - /// # use solana_client::{ - /// # rpc_client::RpcClient, - /// # client_error::ClientError, - /// # }; + /// # use solana_rpc_client_api::client_error::Error; + /// # use solana_rpc_client::rpc_client::RpcClient; /// # use solana_sdk::{ /// # signature::Signer, /// # signer::keypair::Keypair, @@ -3371,7 +3274,7 @@ impl RpcClient { /// &pubkeys, /// commitment_config, /// )?; - /// # Ok::<(), ClientError>(()) + /// # Ok::<(), Error>(()) /// ``` pub fn get_multiple_accounts_with_commitment( &self, @@ -3395,11 +3298,11 @@ impl RpcClient { /// # Examples /// /// ``` - /// # use solana_client::{ - /// # rpc_client::RpcClient, - /// # rpc_config::RpcAccountInfoConfig, - /// # client_error::ClientError, + /// # use solana_rpc_client_api::{ + /// # config::RpcAccountInfoConfig, + /// # client_error::Error, /// # }; + /// # use solana_rpc_client::rpc_client::RpcClient; /// # use solana_sdk::{ /// # signature::Signer, /// # signer::keypair::Keypair, @@ -3420,7 +3323,7 @@ impl RpcClient { /// &pubkeys, /// config, /// )?; - /// # Ok::<(), ClientError>(()) + /// # Ok::<(), Error>(()) /// ``` pub fn get_multiple_accounts_with_config( &self, @@ -3447,10 +3350,8 @@ impl RpcClient { /// # Examples /// /// ``` - /// # use solana_client::{ - /// # rpc_client::{self, RpcClient}, - /// # client_error::ClientError, - /// # }; + /// # use solana_rpc_client_api::client_error::Error; + /// # use solana_rpc_client::rpc_client::{self, RpcClient}; /// # use solana_sdk::{ /// # signature::Signer, /// # signer::keypair::Keypair, @@ -3461,7 +3362,7 @@ impl RpcClient { /// # let rpc_client = RpcClient::new_mock_with_mocks("succeeds".to_string(), mocks); /// let alice_pubkey = Pubkey::from_str("BgvYtJEfmZYdVKiptmMjxGzv8iQoo4MWjsP3QsTkhhxa").unwrap(); /// let account_data = rpc_client.get_account_data(&alice_pubkey)?; - /// # Ok::<(), ClientError>(()) + /// # Ok::<(), Error>(()) /// ``` pub fn get_account_data(&self, pubkey: &Pubkey) -> ClientResult> { self.invoke((self.rpc_client.as_ref()).get_account_data(pubkey)) @@ -3479,14 +3380,12 @@ impl RpcClient { /// # Examples /// /// ``` - /// # use solana_client::{ - /// # rpc_client::RpcClient, - /// # client_error::ClientError, - /// # }; + /// # use solana_rpc_client_api::client_error::Error; + /// # use solana_rpc_client::rpc_client::RpcClient; /// # let rpc_client = RpcClient::new_mock("succeeds".to_string()); /// let data_len = 300; /// let balance = rpc_client.get_minimum_balance_for_rent_exemption(data_len)?; - /// # Ok::<(), ClientError>(()) + /// # Ok::<(), Error>(()) /// ``` pub fn get_minimum_balance_for_rent_exemption(&self, data_len: usize) -> ClientResult { self.invoke((self.rpc_client.as_ref()).get_minimum_balance_for_rent_exemption(data_len)) @@ -3507,10 +3406,8 @@ impl RpcClient { /// # Examples /// /// ``` - /// # use solana_client::{ - /// # rpc_client::RpcClient, - /// # client_error::ClientError, - /// # }; + /// # use solana_rpc_client_api::client_error::Error; + /// # use solana_rpc_client::rpc_client::RpcClient; /// # use solana_sdk::{ /// # signature::Signer, /// # signer::keypair::Keypair, @@ -3518,7 +3415,7 @@ impl RpcClient { /// # let rpc_client = RpcClient::new_mock("succeeds".to_string()); /// # let alice = Keypair::new(); /// let balance = rpc_client.get_balance(&alice.pubkey())?; - /// # Ok::<(), ClientError>(()) + /// # Ok::<(), Error>(()) /// ``` pub fn get_balance(&self, pubkey: &Pubkey) -> ClientResult { self.invoke((self.rpc_client.as_ref()).get_balance(pubkey)) @@ -3535,10 +3432,8 @@ impl RpcClient { /// # Examples /// /// ``` - /// # use solana_client::{ - /// # rpc_client::RpcClient, - /// # client_error::ClientError, - /// # }; + /// # use solana_rpc_client_api::client_error::Error; + /// # use solana_rpc_client::rpc_client::RpcClient; /// # use solana_sdk::{ /// # signature::Signer, /// # signer::keypair::Keypair, @@ -3551,7 +3446,7 @@ impl RpcClient { /// &alice.pubkey(), /// commitment_config, /// )?; - /// # Ok::<(), ClientError>(()) + /// # Ok::<(), Error>(()) /// ``` pub fn get_balance_with_commitment( &self, @@ -3579,10 +3474,8 @@ impl RpcClient { /// # Examples /// /// ``` - /// # use solana_client::{ - /// # rpc_client::RpcClient, - /// # client_error::ClientError, - /// # }; + /// # use solana_rpc_client_api::client_error::Error; + /// # use solana_rpc_client::rpc_client::RpcClient; /// # use solana_sdk::{ /// # signature::Signer, /// # signer::keypair::Keypair, @@ -3590,7 +3483,7 @@ impl RpcClient { /// # let rpc_client = RpcClient::new_mock("succeeds".to_string()); /// # let alice = Keypair::new(); /// let accounts = rpc_client.get_program_accounts(&alice.pubkey())?; - /// # Ok::<(), ClientError>(()) + /// # Ok::<(), Error>(()) /// ``` pub fn get_program_accounts(&self, pubkey: &Pubkey) -> ClientResult> { self.invoke((self.rpc_client.as_ref()).get_program_accounts(pubkey)) @@ -3607,12 +3500,12 @@ impl RpcClient { /// # Examples /// /// ``` - /// # use solana_client::{ - /// # rpc_client::RpcClient, - /// # client_error::ClientError, - /// # rpc_config::{RpcAccountInfoConfig, RpcProgramAccountsConfig}, - /// # rpc_filter::{MemcmpEncodedBytes, RpcFilterType, Memcmp}, + /// # use solana_rpc_client_api::{ + /// # client_error::Error, + /// # config::{RpcAccountInfoConfig, RpcProgramAccountsConfig}, + /// # filter::{MemcmpEncodedBytes, RpcFilterType, Memcmp}, /// # }; + /// # use solana_rpc_client::rpc_client::RpcClient; /// # use solana_sdk::{ /// # signature::Signer, /// # signer::keypair::Keypair, @@ -3650,7 +3543,7 @@ impl RpcClient { /// &alice.pubkey(), /// config, /// )?; - /// # Ok::<(), ClientError>(()) + /// # Ok::<(), Error>(()) /// ``` pub fn get_program_accounts_with_config( &self, @@ -3671,13 +3564,11 @@ impl RpcClient { /// # Examples /// /// ``` - /// # use solana_client::{ - /// # rpc_client::RpcClient, - /// # client_error::ClientError, - /// # }; + /// # use solana_rpc_client_api::client_error::Error; + /// # use solana_rpc_client::rpc_client::RpcClient; /// # let rpc_client = RpcClient::new_mock("succeeds".to_string()); /// let stake_minimum_delegation = rpc_client.get_stake_minimum_delegation()?; - /// # Ok::<(), ClientError>(()) + /// # Ok::<(), Error>(()) /// ``` pub fn get_stake_minimum_delegation(&self) -> ClientResult { self.invoke((self.rpc_client.as_ref()).get_stake_minimum_delegation()) @@ -3694,15 +3585,13 @@ impl RpcClient { /// # Examples /// /// ``` - /// # use solana_client::{ - /// # rpc_client::RpcClient, - /// # client_error::ClientError, - /// # }; + /// # use solana_rpc_client_api::client_error::Error; + /// # use solana_rpc_client::rpc_client::RpcClient; /// # use solana_sdk::commitment_config::CommitmentConfig; /// # let rpc_client = RpcClient::new_mock("succeeds".to_string()); /// let stake_minimum_delegation = /// rpc_client.get_stake_minimum_delegation_with_commitment(CommitmentConfig::confirmed())?; - /// # Ok::<(), ClientError>(()) + /// # Ok::<(), Error>(()) /// ``` pub fn get_stake_minimum_delegation_with_commitment( &self, @@ -4064,11 +3953,11 @@ impl RpcClient { tokio::task::block_in_place(move || self.runtime.as_ref().expect("runtime").block_on(f)) } - pub(crate) fn get_inner_client(&self) -> &Arc { + pub fn get_inner_client(&self) -> &Arc { &self.rpc_client } - pub(crate) fn runtime(&self) -> &tokio::runtime::Runtime { + pub fn runtime(&self) -> &tokio::runtime::Runtime { self.runtime.as_ref().expect("runtime") } } @@ -4107,12 +3996,13 @@ pub fn create_rpc_client_mocks() -> crate::mock_sender::Mocks { mod tests { use { super::*, - crate::{client_error::ClientErrorKind, mock_sender::PUBKEY}, + crate::mock_sender::PUBKEY, assert_matches::assert_matches, crossbeam_channel::unbounded, jsonrpc_core::{futures::prelude::*, Error, IoHandler, Params}, jsonrpc_http_server::{AccessControlAllowOrigin, DomainsValidation, ServerBuilder}, serde_json::{json, Number}, + solana_rpc_client_api::client_error::ErrorKind, solana_sdk::{ instruction::InstructionError, signature::{Keypair, Signer}, @@ -4282,7 +4172,7 @@ mod tests { let result = rpc_client.send_and_confirm_transaction(&tx); assert_matches!( result.unwrap_err().kind(), - ClientErrorKind::TransactionError(TransactionError::InstructionError( + ErrorKind::TransactionError(TransactionError::InstructionError( 0, InstructionError::UninitializedAccount )) @@ -4290,7 +4180,7 @@ mod tests { let rpc_client = RpcClient::new_mock("sig_not_found".to_string()); let result = rpc_client.send_and_confirm_transaction(&tx); - if let ClientErrorKind::Io(err) = result.unwrap_err().kind() { + if let ErrorKind::Io(err) = result.unwrap_err().kind() { assert_eq!(err.kind(), io::ErrorKind::Other); } } diff --git a/client/src/rpc_sender.rs b/rpc-client/src/rpc_sender.rs similarity index 93% rename from client/src/rpc_sender.rs rename to rpc-client/src/rpc_sender.rs index dded04dfc6..948ac45a46 100644 --- a/client/src/rpc_sender.rs +++ b/rpc-client/src/rpc_sender.rs @@ -1,7 +1,7 @@ //! A transport for RPC calls. use { - crate::{client_error::Result, rpc_request::RpcRequest}, async_trait::async_trait, + solana_rpc_client_api::{client_error::Result, request::RpcRequest}, std::time::Duration, }; diff --git a/rpc-client/src/spinner.rs b/rpc-client/src/spinner.rs new file mode 100644 index 0000000000..975a8d9935 --- /dev/null +++ b/rpc-client/src/spinner.rs @@ -0,0 +1,17 @@ +//! Spinner creator + +use { + indicatif::{ProgressBar, ProgressStyle}, + std::time::Duration, +}; + +pub fn new_progress_bar() -> ProgressBar { + let progress_bar = ProgressBar::new(42); + progress_bar.set_style( + ProgressStyle::default_spinner() + .template("{spinner:.green} {wide_msg}") + .expect("ProgresStyle::template direct input to be correct"), + ); + progress_bar.enable_steady_tick(Duration::from_millis(100)); + progress_bar +} diff --git a/rpc/src/lib.rs b/rpc/src/lib.rs index e934981ac1..d021155e89 100644 --- a/rpc/src/lib.rs +++ b/rpc/src/lib.rs @@ -4,6 +4,7 @@ pub mod max_slots; pub mod optimistically_confirmed_bank_tracker; pub mod parsed_token_accounts; pub mod rpc; +mod rpc_cache; pub mod rpc_completed_slots_service; pub mod rpc_health; pub mod rpc_pubsub; diff --git a/rpc/src/rpc.rs b/rpc/src/rpc.rs index 9cad136b58..03c74aa1ba 100644 --- a/rpc/src/rpc.rs +++ b/rpc/src/rpc.rs @@ -3,7 +3,7 @@ use { crate::{ max_slots::MaxSlots, optimistically_confirmed_bank_tracker::OptimisticallyConfirmedBank, - parsed_token_accounts::*, rpc_health::*, + parsed_token_accounts::*, rpc_cache::LargestAccountsCache, rpc_health::*, }, bincode::{config::Options, serialize}, crossbeam_channel::{unbounded, Receiver, Sender}, @@ -16,7 +16,6 @@ use { }, solana_client::{ connection_cache::ConnectionCache, - rpc_cache::LargestAccountsCache, rpc_config::*, rpc_custom_error::RpcCustomError, rpc_deprecated_config::*, diff --git a/client/src/rpc_cache.rs b/rpc/src/rpc_cache.rs similarity index 89% rename from client/src/rpc_cache.rs rename to rpc/src/rpc_cache.rs index 4207d3ce36..0f92a3336d 100644 --- a/client/src/rpc_cache.rs +++ b/rpc/src/rpc_cache.rs @@ -1,5 +1,5 @@ use { - crate::{rpc_config::RpcLargestAccountsFilter, rpc_response::RpcAccountBalance}, + solana_client::{rpc_config::RpcLargestAccountsFilter, rpc_response::RpcAccountBalance}, std::{ collections::HashMap, time::{Duration, SystemTime}, @@ -20,14 +20,14 @@ struct LargestAccountsCacheValue { } impl LargestAccountsCache { - pub fn new(duration: u64) -> Self { + pub(crate) fn new(duration: u64) -> Self { Self { duration, cache: HashMap::new(), } } - pub fn get_largest_accounts( + pub(crate) fn get_largest_accounts( &self, filter: &Option, ) -> Option<(u64, Vec)> { @@ -41,7 +41,7 @@ impl LargestAccountsCache { }) } - pub fn set_largest_accounts( + pub(crate) fn set_largest_accounts( &mut self, filter: &Option, slot: u64, diff --git a/rpc/src/rpc_service.rs b/rpc/src/rpc_service.rs index a74b46e7ea..37fc44bcbf 100644 --- a/rpc/src/rpc_service.rs +++ b/rpc/src/rpc_service.rs @@ -9,6 +9,7 @@ use { rpc_accounts::*, rpc_bank::*, rpc_deprecated_v1_7::*, rpc_deprecated_v1_9::*, rpc_full::*, rpc_minimal::*, rpc_obsolete_v1_7::*, *, }, + rpc_cache::LargestAccountsCache, rpc_health::*, }, crossbeam_channel::unbounded, @@ -18,7 +19,7 @@ use { RequestMiddlewareAction, ServerBuilder, }, regex::Regex, - solana_client::{connection_cache::ConnectionCache, rpc_cache::LargestAccountsCache}, + solana_client::connection_cache::ConnectionCache, solana_gossip::cluster_info::ClusterInfo, solana_ledger::{ bigtable_upload::ConfirmedBlockUploadConfig, diff --git a/thin-client/Cargo.toml b/thin-client/Cargo.toml new file mode 100644 index 0000000000..a075ee7e44 --- /dev/null +++ b/thin-client/Cargo.toml @@ -0,0 +1,25 @@ +[package] +name = "solana-thin-client" +version = "1.12.0" +description = "Solana Thin Client" +authors = ["Solana Maintainers "] +repository = "https://github.com/solana-labs/solana" +license = "Apache-2.0" +homepage = "https://solana.com/" +documentation = "https://docs.rs/solana-thin-client" +edition = "2021" + +[dependencies] +bincode = "1.3.3" +log = "0.4.17" +solana-rpc-client = { path = "../rpc-client", version = "=1.12.0" } +solana-rpc-client-api = { path = "../rpc-client-api", version = "=1.12.0" } +solana-sdk = { path = "../sdk", version = "=1.12.0" } +solana-tpu-client = { path = "../tpu-client", version = "=1.12.0" } + +[dev-dependencies] +rayon = "1.5.3" +solana-logger = { path = "../logger", version = "=1.12.0" } + +[package.metadata.docs.rs] +targets = ["x86_64-unknown-linux-gnu"] diff --git a/thin-client/src/lib.rs b/thin-client/src/lib.rs new file mode 100644 index 0000000000..afb3489f2a --- /dev/null +++ b/thin-client/src/lib.rs @@ -0,0 +1,3 @@ +#![allow(clippy::integer_arithmetic)] + +pub mod thin_client; diff --git a/client/src/thin_client.rs b/thin-client/src/thin_client.rs similarity index 98% rename from client/src/thin_client.rs rename to thin-client/src/thin_client.rs index de211c50a5..b18b5f3ee8 100644 --- a/client/src/thin_client.rs +++ b/thin-client/src/thin_client.rs @@ -4,12 +4,9 @@ //! unstable and may change in future releases. use { - crate::{ - connection_cache::ConnectionCache, rpc_client::RpcClient, - rpc_config::RpcProgramAccountsConfig, rpc_response::Response, - tpu_connection::TpuConnection, - }, log::*, + solana_rpc_client::rpc_client::RpcClient, + solana_rpc_client_api::{config::RpcProgramAccountsConfig, response::Response}, solana_sdk::{ account::Account, client::{AsyncClient, Client, SyncClient}, @@ -28,6 +25,7 @@ use { transaction::{self, Transaction, VersionedTransaction}, transport::Result as TransportResult, }, + solana_tpu_client::{connection_cache::ConnectionCache, tpu_connection::TpuConnection}, std::{ io, net::SocketAddr, diff --git a/tpu-client/.gitignore b/tpu-client/.gitignore new file mode 100644 index 0000000000..5404b132db --- /dev/null +++ b/tpu-client/.gitignore @@ -0,0 +1,2 @@ +/target/ +/farf/ diff --git a/tpu-client/Cargo.toml b/tpu-client/Cargo.toml new file mode 100644 index 0000000000..be54e64bd5 --- /dev/null +++ b/tpu-client/Cargo.toml @@ -0,0 +1,48 @@ +[package] +name = "solana-tpu-client" +version = "1.12.0" +description = "Solana TPU Client" +authors = ["Solana Maintainers "] +repository = "https://github.com/solana-labs/solana" +license = "Apache-2.0" +homepage = "https://solana.com/" +documentation = "https://docs.rs/solana-tpu-client" +edition = "2021" + +[dependencies] +async-mutex = "1.4.0" +async-trait = "0.1.57" +bincode = "1.3.3" +enum_dispatch = "0.3.8" +futures = "0.3" +futures-util = "0.3.21" +indexmap = "1.9.1" +indicatif = "0.17.0" +itertools = "0.10.2" +lazy_static = "1.4.0" +log = "0.4.17" +quinn = "0.8.4" +quinn-proto = "0.8.4" +quinn-udp = "0.1.3" +rand = "0.7.0" +rayon = "1.5.3" +rustls = { version = "0.20.6", features = ["dangerous_configuration"] } +solana-measure = { path = "../measure", version = "=1.12.0" } +solana-metrics = { path = "../metrics", version = "=1.12.0" } +solana-net-utils = { path = "../net-utils", version = "=1.12.0" } +solana-pubsub-client = { path = "../pubsub-client", version = "=1.12.0" } +solana-rpc-client = { path = "../rpc-client", version = "=1.12.0" } +solana-rpc-client-api = { path = "../rpc-client-api", version = "=1.12.0" } +solana-sdk = { path = "../sdk", version = "=1.12.0" } +solana-streamer = { path = "../streamer", version = "=1.12.0" } +thiserror = "1.0" +tokio = { version = "1", features = ["full"] } + +[dev-dependencies] +crossbeam-channel = "0.5" +rand_chacha = "0.2.2" +solana-logger = { path = "../logger", version = "=1.12.0" } +solana-perf = { path = "../perf", version = "=1.12.0" } + +[package.metadata.docs.rs] +targets = ["x86_64-unknown-linux-gnu"] diff --git a/client/src/connection_cache.rs b/tpu-client/src/connection_cache.rs similarity index 100% rename from client/src/connection_cache.rs rename to tpu-client/src/connection_cache.rs diff --git a/tpu-client/src/lib.rs b/tpu-client/src/lib.rs new file mode 100644 index 0000000000..d1ff8c895a --- /dev/null +++ b/tpu-client/src/lib.rs @@ -0,0 +1,11 @@ +#![allow(clippy::integer_arithmetic)] + +pub mod connection_cache; +pub mod nonblocking; +pub mod quic_client; +pub mod tpu_client; +pub mod tpu_connection; +pub mod udp_client; + +#[macro_use] +extern crate solana_metrics; diff --git a/tpu-client/src/nonblocking/mod.rs b/tpu-client/src/nonblocking/mod.rs new file mode 100644 index 0000000000..69860d7bff --- /dev/null +++ b/tpu-client/src/nonblocking/mod.rs @@ -0,0 +1,4 @@ +pub mod quic_client; +pub mod tpu_client; +pub mod tpu_connection; +pub mod udp_client; diff --git a/client/src/nonblocking/quic_client.rs b/tpu-client/src/nonblocking/quic_client.rs similarity index 97% rename from client/src/nonblocking/quic_client.rs rename to tpu-client/src/nonblocking/quic_client.rs index 153937203a..295460aabc 100644 --- a/client/src/nonblocking/quic_client.rs +++ b/tpu-client/src/nonblocking/quic_client.rs @@ -3,8 +3,8 @@ //! server's flow control. use { crate::{ - client_error::ClientErrorKind, connection_cache::ConnectionCacheStats, - nonblocking::tpu_connection::TpuConnection, tpu_connection::ClientStats, + connection_cache::ConnectionCacheStats, nonblocking::tpu_connection::TpuConnection, + tpu_connection::ClientStats, }, async_mutex::Mutex, async_trait::async_trait, @@ -17,6 +17,7 @@ use { }, solana_measure::measure::Measure, solana_net_utils::VALIDATOR_PORT_RANGE, + solana_rpc_client_api::client_error::ErrorKind as ClientErrorKind, solana_sdk::{ quic::{ QUIC_CONNECTION_HANDSHAKE_TIMEOUT_MS, QUIC_KEEP_ALIVE_MS, QUIC_MAX_TIMEOUT_MS, @@ -82,6 +83,12 @@ pub enum QuicError { ConnectError(#[from] ConnectError), } +impl From for ClientErrorKind { + fn from(quic_error: QuicError) -> Self { + Self::Custom(format!("{:?}", quic_error)) + } +} + impl QuicLazyInitializedEndpoint { pub fn new(client_certificate: Arc) -> Self { Self { @@ -439,7 +446,8 @@ impl QuicClient { T: AsRef<[u8]>, { self._send_buffer(data.as_ref(), stats, connection_stats) - .await?; + .await + .map_err(Into::::into)?; Ok(()) } @@ -483,7 +491,8 @@ impl QuicClient { } let connection = self ._send_buffer(buffers[0].as_ref(), stats, connection_stats) - .await?; + .await + .map_err(Into::::into)?; // Used to avoid dereferencing the Arc multiple times below // by just getting a reference to the NewConnection once @@ -504,7 +513,10 @@ impl QuicClient { .collect(); for f in futures { - f.await.into_iter().try_for_each(|res| res)?; + f.await + .into_iter() + .try_for_each(|res| res) + .map_err(Into::::into)?; } Ok(()) } diff --git a/client/src/nonblocking/tpu_client.rs b/tpu-client/src/nonblocking/tpu_client.rs similarity index 94% rename from client/src/nonblocking/tpu_client.rs rename to tpu-client/src/nonblocking/tpu_client.rs index a231b787c4..a09333d0b1 100644 --- a/client/src/nonblocking/tpu_client.rs +++ b/tpu-client/src/nonblocking/tpu_client.rs @@ -1,15 +1,7 @@ use { crate::{ - client_error::{ClientError, Result as ClientResult}, connection_cache::ConnectionCache, - nonblocking::{ - pubsub_client::{PubsubClient, PubsubClientError}, - rpc_client::RpcClient, - tpu_connection::TpuConnection, - }, - rpc_request::MAX_GET_SIGNATURE_STATUSES_QUERY_ITEMS, - rpc_response::{RpcContactInfo, SlotUpdate}, - spinner, + nonblocking::tpu_connection::TpuConnection, tpu_client::{ RecentLeaderSlots, TpuClientConfig, MAX_FANOUT_SLOTS, SEND_TRANSACTION_INTERVAL, TRANSACTION_RESEND_INTERVAL, @@ -17,7 +9,15 @@ use { }, bincode::serialize, futures_util::{future::join_all, stream::StreamExt}, + indicatif::ProgressBar, log::*, + solana_pubsub_client::nonblocking::pubsub_client::{PubsubClient, PubsubClientError}, + solana_rpc_client::{nonblocking::rpc_client::RpcClient, spinner}, + solana_rpc_client_api::{ + client_error::{Error as ClientError, Result as ClientResult}, + request::MAX_GET_SIGNATURE_STATUSES_QUERY_ITEMS, + response::{RpcContactInfo, SlotUpdate}, + }, solana_sdk::{ clock::Slot, commitment_config::CommitmentConfig, @@ -366,7 +366,7 @@ impl TpuClient { if !self.send_transaction(transaction).await { let _result = self.rpc_client.send_transaction(transaction).await.ok(); } - spinner::set_message_for_confirmed_transactions( + set_message_for_confirmed_transactions( &progress_bar, confirmed_transactions, total_transactions, @@ -381,7 +381,7 @@ impl TpuClient { // Wait for the next block before checking for transaction statuses let mut block_height_refreshes = 10; - spinner::set_message_for_confirmed_transactions( + set_message_for_confirmed_transactions( &progress_bar, confirmed_transactions, total_transactions, @@ -430,7 +430,7 @@ impl TpuClient { } } } - spinner::set_message_for_confirmed_transactions( + set_message_for_confirmed_transactions( &progress_bar, confirmed_transactions, total_transactions, @@ -666,3 +666,26 @@ async fn maybe_fetch_cache_info( maybe_slot_leaders, } } + +fn set_message_for_confirmed_transactions( + progress_bar: &ProgressBar, + confirmed_transactions: u32, + total_transactions: usize, + block_height: Option, + last_valid_block_height: u64, + status: &str, +) { + progress_bar.set_message(format!( + "{:>5.1}% | {:<40}{}", + confirmed_transactions as f64 * 100. / total_transactions as f64, + status, + match block_height { + Some(block_height) => format!( + " [block height {}; re-sign in {} blocks]", + block_height, + last_valid_block_height.saturating_sub(block_height), + ), + None => String::new(), + }, + )); +} diff --git a/client/src/nonblocking/tpu_connection.rs b/tpu-client/src/nonblocking/tpu_connection.rs similarity index 100% rename from client/src/nonblocking/tpu_connection.rs rename to tpu-client/src/nonblocking/tpu_connection.rs diff --git a/client/src/nonblocking/udp_client.rs b/tpu-client/src/nonblocking/udp_client.rs similarity index 100% rename from client/src/nonblocking/udp_client.rs rename to tpu-client/src/nonblocking/udp_client.rs diff --git a/client/src/quic_client.rs b/tpu-client/src/quic_client.rs similarity index 100% rename from client/src/quic_client.rs rename to tpu-client/src/quic_client.rs diff --git a/client/src/tpu_client.rs b/tpu-client/src/tpu_client.rs similarity index 99% rename from client/src/tpu_client.rs rename to tpu-client/src/tpu_client.rs index 3f3c8d2dce..3de665842e 100644 --- a/client/src/tpu_client.rs +++ b/tpu-client/src/tpu_client.rs @@ -2,8 +2,9 @@ pub use crate::nonblocking::tpu_client::TpuSenderError; use { crate::{ connection_cache::ConnectionCache, - nonblocking::tpu_client::TpuClient as NonblockingTpuClient, rpc_client::RpcClient, + nonblocking::tpu_client::TpuClient as NonblockingTpuClient, }, + solana_rpc_client::rpc_client::RpcClient, solana_sdk::{ clock::Slot, message::Message, diff --git a/client/src/tpu_connection.rs b/tpu-client/src/tpu_connection.rs similarity index 100% rename from client/src/tpu_connection.rs rename to tpu-client/src/tpu_connection.rs diff --git a/client/src/udp_client.rs b/tpu-client/src/udp_client.rs similarity index 100% rename from client/src/udp_client.rs rename to tpu-client/src/udp_client.rs diff --git a/client/tests/quic_client.rs b/tpu-client/tests/quic_client.rs similarity index 96% rename from client/tests/quic_client.rs rename to tpu-client/tests/quic_client.rs index 1c5348177d..9ce9a1ffcd 100644 --- a/client/tests/quic_client.rs +++ b/tpu-client/tests/quic_client.rs @@ -2,13 +2,13 @@ mod tests { use { crossbeam_channel::{unbounded, Receiver}, - solana_client::{ - connection_cache::ConnectionCacheStats, - nonblocking::quic_client::QuicLazyInitializedEndpoint, - }, solana_perf::packet::PacketBatch, solana_sdk::{packet::PACKET_DATA_SIZE, signature::Keypair}, solana_streamer::{quic::StreamStats, streamer::StakedNodes}, + solana_tpu_client::{ + connection_cache::ConnectionCacheStats, + nonblocking::quic_client::QuicLazyInitializedEndpoint, + }, std::{ net::{IpAddr, SocketAddr, UdpSocket}, sync::{ @@ -62,7 +62,7 @@ mod tests { #[test] fn test_quic_client_multiple_writes() { - use solana_client::{quic_client::QuicTpuConnection, tpu_connection::TpuConnection}; + use solana_tpu_client::{quic_client::QuicTpuConnection, tpu_connection::TpuConnection}; solana_logger::setup(); let (sender, receiver) = unbounded(); let staked_nodes = Arc::new(RwLock::new(StakedNodes::default())); @@ -105,7 +105,7 @@ mod tests { #[tokio::test] async fn test_nonblocking_quic_client_multiple_writes() { - use solana_client::nonblocking::{ + use solana_tpu_client::nonblocking::{ quic_client::QuicTpuConnection, tpu_connection::TpuConnection, }; solana_logger::setup();