Refactor - Demotes `Arc` to `Rc`. (#32982)

Demotes `Arc` to `Rc`.
This commit is contained in:
Alexander Meißner 2023-08-25 00:54:06 +02:00 committed by GitHub
parent 68456fad86
commit 67d6d688cc
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
22 changed files with 115 additions and 110 deletions

View File

@ -14,7 +14,7 @@ use {
pubkey::Pubkey, pubkey::Pubkey,
signature::{read_keypair_file, Keypair, Signature, Signer}, signature::{read_keypair_file, Keypair, Signature, Signer},
}, },
std::{str::FromStr, sync::Arc}, std::{rc::Rc, str::FromStr},
}; };
// Sentinel value used to indicate to write to screen instead of file // Sentinel value used to indicate to write to screen instead of file
@ -123,7 +123,7 @@ pub fn pubkeys_sigs_of(matches: &ArgMatches<'_>, name: &str) -> Option<Vec<(Pubk
pub fn signer_of( pub fn signer_of(
matches: &ArgMatches<'_>, matches: &ArgMatches<'_>,
name: &str, name: &str,
wallet_manager: &mut Option<Arc<RemoteWalletManager>>, wallet_manager: &mut Option<Rc<RemoteWalletManager>>,
) -> Result<(Option<Box<dyn Signer>>, Option<Pubkey>), Box<dyn std::error::Error>> { ) -> Result<(Option<Box<dyn Signer>>, Option<Pubkey>), Box<dyn std::error::Error>> {
if let Some(location) = matches.value_of(name) { if let Some(location) = matches.value_of(name) {
let signer = signer_from_path(matches, location, name, wallet_manager)?; let signer = signer_from_path(matches, location, name, wallet_manager)?;
@ -137,7 +137,7 @@ pub fn signer_of(
pub fn pubkey_of_signer( pub fn pubkey_of_signer(
matches: &ArgMatches<'_>, matches: &ArgMatches<'_>,
name: &str, name: &str,
wallet_manager: &mut Option<Arc<RemoteWalletManager>>, wallet_manager: &mut Option<Rc<RemoteWalletManager>>,
) -> Result<Option<Pubkey>, Box<dyn std::error::Error>> { ) -> Result<Option<Pubkey>, Box<dyn std::error::Error>> {
if let Some(location) = matches.value_of(name) { if let Some(location) = matches.value_of(name) {
Ok(Some(pubkey_from_path( Ok(Some(pubkey_from_path(
@ -154,7 +154,7 @@ pub fn pubkey_of_signer(
pub fn pubkeys_of_multiple_signers( pub fn pubkeys_of_multiple_signers(
matches: &ArgMatches<'_>, matches: &ArgMatches<'_>,
name: &str, name: &str,
wallet_manager: &mut Option<Arc<RemoteWalletManager>>, wallet_manager: &mut Option<Rc<RemoteWalletManager>>,
) -> Result<Option<Vec<Pubkey>>, Box<dyn std::error::Error>> { ) -> Result<Option<Vec<Pubkey>>, Box<dyn std::error::Error>> {
if let Some(pubkey_matches) = matches.values_of(name) { if let Some(pubkey_matches) = matches.values_of(name) {
let mut pubkeys: Vec<Pubkey> = vec![]; let mut pubkeys: Vec<Pubkey> = vec![];
@ -170,7 +170,7 @@ pub fn pubkeys_of_multiple_signers(
pub fn resolve_signer( pub fn resolve_signer(
matches: &ArgMatches<'_>, matches: &ArgMatches<'_>,
name: &str, name: &str,
wallet_manager: &mut Option<Arc<RemoteWalletManager>>, wallet_manager: &mut Option<Rc<RemoteWalletManager>>,
) -> Result<Option<String>, Box<dyn std::error::Error>> { ) -> Result<Option<String>, Box<dyn std::error::Error>> {
resolve_signer_from_path( resolve_signer_from_path(
matches, matches,

View File

@ -41,8 +41,8 @@ use {
io::{stdin, stdout, Write}, io::{stdin, stdout, Write},
ops::Deref, ops::Deref,
process::exit, process::exit,
rc::Rc,
str::FromStr, str::FromStr,
sync::Arc,
}, },
thiserror::Error, thiserror::Error,
}; };
@ -242,7 +242,7 @@ impl DefaultSigner {
&self, &self,
bulk_signers: Vec<Option<Box<dyn Signer>>>, bulk_signers: Vec<Option<Box<dyn Signer>>>,
matches: &ArgMatches<'_>, matches: &ArgMatches<'_>,
wallet_manager: &mut Option<Arc<RemoteWalletManager>>, wallet_manager: &mut Option<Rc<RemoteWalletManager>>,
) -> Result<CliSignerInfo, Box<dyn error::Error>> { ) -> Result<CliSignerInfo, Box<dyn error::Error>> {
let mut unique_signers = vec![]; let mut unique_signers = vec![];
@ -304,7 +304,7 @@ impl DefaultSigner {
pub fn signer_from_path( pub fn signer_from_path(
&self, &self,
matches: &ArgMatches, matches: &ArgMatches,
wallet_manager: &mut Option<Arc<RemoteWalletManager>>, wallet_manager: &mut Option<Rc<RemoteWalletManager>>,
) -> Result<Box<dyn Signer>, Box<dyn std::error::Error>> { ) -> Result<Box<dyn Signer>, Box<dyn std::error::Error>> {
signer_from_path(matches, self.path()?, &self.arg_name, wallet_manager) signer_from_path(matches, self.path()?, &self.arg_name, wallet_manager)
} }
@ -357,7 +357,7 @@ impl DefaultSigner {
pub fn signer_from_path_with_config( pub fn signer_from_path_with_config(
&self, &self,
matches: &ArgMatches, matches: &ArgMatches,
wallet_manager: &mut Option<Arc<RemoteWalletManager>>, wallet_manager: &mut Option<Rc<RemoteWalletManager>>,
config: &SignerFromPathConfig, config: &SignerFromPathConfig,
) -> Result<Box<dyn Signer>, Box<dyn std::error::Error>> { ) -> Result<Box<dyn Signer>, Box<dyn std::error::Error>> {
signer_from_path_with_config( signer_from_path_with_config(
@ -686,7 +686,7 @@ pub fn signer_from_path(
matches: &ArgMatches, matches: &ArgMatches,
path: &str, path: &str,
keypair_name: &str, keypair_name: &str,
wallet_manager: &mut Option<Arc<RemoteWalletManager>>, wallet_manager: &mut Option<Rc<RemoteWalletManager>>,
) -> Result<Box<dyn Signer>, Box<dyn error::Error>> { ) -> Result<Box<dyn Signer>, Box<dyn error::Error>> {
let config = SignerFromPathConfig::default(); let config = SignerFromPathConfig::default();
signer_from_path_with_config(matches, path, keypair_name, wallet_manager, &config) signer_from_path_with_config(matches, path, keypair_name, wallet_manager, &config)
@ -753,7 +753,7 @@ pub fn signer_from_path_with_config(
matches: &ArgMatches, matches: &ArgMatches,
path: &str, path: &str,
keypair_name: &str, keypair_name: &str,
wallet_manager: &mut Option<Arc<RemoteWalletManager>>, wallet_manager: &mut Option<Rc<RemoteWalletManager>>,
config: &SignerFromPathConfig, config: &SignerFromPathConfig,
) -> Result<Box<dyn Signer>, Box<dyn error::Error>> { ) -> Result<Box<dyn Signer>, Box<dyn error::Error>> {
let SignerSource { let SignerSource {
@ -860,7 +860,7 @@ pub fn pubkey_from_path(
matches: &ArgMatches, matches: &ArgMatches,
path: &str, path: &str,
keypair_name: &str, keypair_name: &str,
wallet_manager: &mut Option<Arc<RemoteWalletManager>>, wallet_manager: &mut Option<Rc<RemoteWalletManager>>,
) -> Result<Pubkey, Box<dyn error::Error>> { ) -> Result<Pubkey, Box<dyn error::Error>> {
let SignerSource { kind, .. } = parse_signer_source(path)?; let SignerSource { kind, .. } = parse_signer_source(path)?;
match kind { match kind {
@ -873,7 +873,7 @@ pub fn resolve_signer_from_path(
matches: &ArgMatches, matches: &ArgMatches,
path: &str, path: &str,
keypair_name: &str, keypair_name: &str,
wallet_manager: &mut Option<Arc<RemoteWalletManager>>, wallet_manager: &mut Option<Rc<RemoteWalletManager>>,
) -> Result<Option<String>, Box<dyn error::Error>> { ) -> Result<Option<String>, Box<dyn error::Error>> {
let SignerSource { let SignerSource {
kind, kind,

View File

@ -14,7 +14,7 @@ use {
pubkey::Pubkey, pubkey::Pubkey,
signature::{read_keypair_file, Keypair, Signature, Signer}, signature::{read_keypair_file, Keypair, Signature, Signer},
}, },
std::{str::FromStr, sync::Arc}, std::{rc::Rc, str::FromStr},
}; };
// Sentinel value used to indicate to write to screen instead of file // Sentinel value used to indicate to write to screen instead of file
@ -123,7 +123,7 @@ pub fn pubkeys_sigs_of(matches: &ArgMatches, name: &str) -> Option<Vec<(Pubkey,
pub fn signer_of( pub fn signer_of(
matches: &ArgMatches, matches: &ArgMatches,
name: &str, name: &str,
wallet_manager: &mut Option<Arc<RemoteWalletManager>>, wallet_manager: &mut Option<Rc<RemoteWalletManager>>,
) -> Result<(Option<Box<dyn Signer>>, Option<Pubkey>), Box<dyn std::error::Error>> { ) -> Result<(Option<Box<dyn Signer>>, Option<Pubkey>), Box<dyn std::error::Error>> {
if let Some(location) = matches.value_of(name) { if let Some(location) = matches.value_of(name) {
let signer = signer_from_path(matches, location, name, wallet_manager)?; let signer = signer_from_path(matches, location, name, wallet_manager)?;
@ -137,7 +137,7 @@ pub fn signer_of(
pub fn pubkey_of_signer( pub fn pubkey_of_signer(
matches: &ArgMatches, matches: &ArgMatches,
name: &str, name: &str,
wallet_manager: &mut Option<Arc<RemoteWalletManager>>, wallet_manager: &mut Option<Rc<RemoteWalletManager>>,
) -> Result<Option<Pubkey>, Box<dyn std::error::Error>> { ) -> Result<Option<Pubkey>, Box<dyn std::error::Error>> {
if let Some(location) = matches.value_of(name) { if let Some(location) = matches.value_of(name) {
Ok(Some(pubkey_from_path( Ok(Some(pubkey_from_path(
@ -154,7 +154,7 @@ pub fn pubkey_of_signer(
pub fn pubkeys_of_multiple_signers( pub fn pubkeys_of_multiple_signers(
matches: &ArgMatches, matches: &ArgMatches,
name: &str, name: &str,
wallet_manager: &mut Option<Arc<RemoteWalletManager>>, wallet_manager: &mut Option<Rc<RemoteWalletManager>>,
) -> Result<Option<Vec<Pubkey>>, Box<dyn std::error::Error>> { ) -> Result<Option<Vec<Pubkey>>, Box<dyn std::error::Error>> {
if let Some(pubkey_matches) = matches.values_of(name) { if let Some(pubkey_matches) = matches.values_of(name) {
let mut pubkeys: Vec<Pubkey> = vec![]; let mut pubkeys: Vec<Pubkey> = vec![];
@ -170,7 +170,7 @@ pub fn pubkeys_of_multiple_signers(
pub fn resolve_signer( pub fn resolve_signer(
matches: &ArgMatches, matches: &ArgMatches,
name: &str, name: &str,
wallet_manager: &mut Option<Arc<RemoteWalletManager>>, wallet_manager: &mut Option<Rc<RemoteWalletManager>>,
) -> Result<Option<String>, Box<dyn std::error::Error>> { ) -> Result<Option<String>, Box<dyn std::error::Error>> {
resolve_signer_from_path( resolve_signer_from_path(
matches, matches,

View File

@ -42,8 +42,8 @@ use {
io::{stdin, stdout, Write}, io::{stdin, stdout, Write},
ops::Deref, ops::Deref,
process::exit, process::exit,
rc::Rc,
str::FromStr, str::FromStr,
sync::Arc,
}, },
thiserror::Error, thiserror::Error,
}; };
@ -243,7 +243,7 @@ impl DefaultSigner {
&self, &self,
bulk_signers: Vec<Option<Box<dyn Signer>>>, bulk_signers: Vec<Option<Box<dyn Signer>>>,
matches: &ArgMatches, matches: &ArgMatches,
wallet_manager: &mut Option<Arc<RemoteWalletManager>>, wallet_manager: &mut Option<Rc<RemoteWalletManager>>,
) -> Result<CliSignerInfo, Box<dyn error::Error>> { ) -> Result<CliSignerInfo, Box<dyn error::Error>> {
let mut unique_signers = vec![]; let mut unique_signers = vec![];
@ -305,7 +305,7 @@ impl DefaultSigner {
pub fn signer_from_path( pub fn signer_from_path(
&self, &self,
matches: &ArgMatches, matches: &ArgMatches,
wallet_manager: &mut Option<Arc<RemoteWalletManager>>, wallet_manager: &mut Option<Rc<RemoteWalletManager>>,
) -> Result<Box<dyn Signer>, Box<dyn std::error::Error>> { ) -> Result<Box<dyn Signer>, Box<dyn std::error::Error>> {
signer_from_path(matches, self.path()?, &self.arg_name, wallet_manager) signer_from_path(matches, self.path()?, &self.arg_name, wallet_manager)
} }
@ -358,7 +358,7 @@ impl DefaultSigner {
pub fn signer_from_path_with_config( pub fn signer_from_path_with_config(
&self, &self,
matches: &ArgMatches, matches: &ArgMatches,
wallet_manager: &mut Option<Arc<RemoteWalletManager>>, wallet_manager: &mut Option<Rc<RemoteWalletManager>>,
config: &SignerFromPathConfig, config: &SignerFromPathConfig,
) -> Result<Box<dyn Signer>, Box<dyn std::error::Error>> { ) -> Result<Box<dyn Signer>, Box<dyn std::error::Error>> {
signer_from_path_with_config( signer_from_path_with_config(
@ -687,7 +687,7 @@ pub fn signer_from_path(
matches: &ArgMatches, matches: &ArgMatches,
path: &str, path: &str,
keypair_name: &str, keypair_name: &str,
wallet_manager: &mut Option<Arc<RemoteWalletManager>>, wallet_manager: &mut Option<Rc<RemoteWalletManager>>,
) -> Result<Box<dyn Signer>, Box<dyn error::Error>> { ) -> Result<Box<dyn Signer>, Box<dyn error::Error>> {
let config = SignerFromPathConfig::default(); let config = SignerFromPathConfig::default();
signer_from_path_with_config(matches, path, keypair_name, wallet_manager, &config) signer_from_path_with_config(matches, path, keypair_name, wallet_manager, &config)
@ -754,7 +754,7 @@ pub fn signer_from_path_with_config(
matches: &ArgMatches, matches: &ArgMatches,
path: &str, path: &str,
keypair_name: &str, keypair_name: &str,
wallet_manager: &mut Option<Arc<RemoteWalletManager>>, wallet_manager: &mut Option<Rc<RemoteWalletManager>>,
config: &SignerFromPathConfig, config: &SignerFromPathConfig,
) -> Result<Box<dyn Signer>, Box<dyn error::Error>> { ) -> Result<Box<dyn Signer>, Box<dyn error::Error>> {
let SignerSource { let SignerSource {
@ -862,7 +862,7 @@ pub fn pubkey_from_path(
matches: &ArgMatches, matches: &ArgMatches,
path: &str, path: &str,
keypair_name: &str, keypair_name: &str,
wallet_manager: &mut Option<Arc<RemoteWalletManager>>, wallet_manager: &mut Option<Rc<RemoteWalletManager>>,
) -> Result<Pubkey, Box<dyn error::Error>> { ) -> Result<Pubkey, Box<dyn error::Error>> {
let SignerSource { kind, .. } = parse_signer_source(path)?; let SignerSource { kind, .. } = parse_signer_source(path)?;
match kind { match kind {
@ -875,7 +875,7 @@ pub fn resolve_signer_from_path(
matches: &ArgMatches, matches: &ArgMatches,
path: &str, path: &str,
keypair_name: &str, keypair_name: &str,
wallet_manager: &mut Option<Arc<RemoteWalletManager>>, wallet_manager: &mut Option<Rc<RemoteWalletManager>>,
) -> Result<Option<String>, Box<dyn error::Error>> { ) -> Result<Option<String>, Box<dyn error::Error>> {
let SignerSource { let SignerSource {
kind, kind,

View File

@ -17,7 +17,7 @@ use {
account::from_account, clock::Clock, commitment_config::CommitmentConfig, message::Message, account::from_account, clock::Clock, commitment_config::CommitmentConfig, message::Message,
pubkey::Pubkey, signer::Signer, sysvar, transaction::Transaction, pubkey::Pubkey, signer::Signer, sysvar, transaction::Transaction,
}, },
std::sync::Arc, std::{rc::Rc, sync::Arc},
}; };
#[derive(Debug, PartialEq, Eq)] #[derive(Debug, PartialEq, Eq)]
@ -234,7 +234,7 @@ impl AddressLookupTableSubCommands for App<'_, '_> {
pub fn parse_address_lookup_table_subcommand( pub fn parse_address_lookup_table_subcommand(
matches: &ArgMatches<'_>, matches: &ArgMatches<'_>,
default_signer: &DefaultSigner, default_signer: &DefaultSigner,
wallet_manager: &mut Option<Arc<RemoteWalletManager>>, wallet_manager: &mut Option<Rc<RemoteWalletManager>>,
) -> Result<CliCommandInfo, CliError> { ) -> Result<CliCommandInfo, CliError> {
let (subcommand, sub_matches) = matches.subcommand(); let (subcommand, sub_matches) = matches.subcommand();

View File

@ -33,7 +33,9 @@ use {
}, },
solana_tpu_client::tpu_client::DEFAULT_TPU_ENABLE_UDP, solana_tpu_client::tpu_client::DEFAULT_TPU_ENABLE_UDP,
solana_vote_program::vote_state::VoteAuthorize, solana_vote_program::vote_state::VoteAuthorize,
std::{collections::HashMap, error, io::stdout, str::FromStr, sync::Arc, time::Duration}, std::{
collections::HashMap, error, io::stdout, rc::Rc, str::FromStr, sync::Arc, time::Duration,
},
thiserror::Error, thiserror::Error,
}; };
@ -568,7 +570,7 @@ impl Default for CliConfig<'_> {
pub fn parse_command( pub fn parse_command(
matches: &ArgMatches<'_>, matches: &ArgMatches<'_>,
default_signer: &DefaultSigner, default_signer: &DefaultSigner,
wallet_manager: &mut Option<Arc<RemoteWalletManager>>, wallet_manager: &mut Option<Rc<RemoteWalletManager>>,
) -> Result<CliCommandInfo, Box<dyn error::Error>> { ) -> Result<CliCommandInfo, Box<dyn error::Error>> {
let response = match matches.subcommand() { let response = match matches.subcommand() {
// Autocompletion Command // Autocompletion Command

View File

@ -70,6 +70,7 @@ use {
std::{ std::{
collections::{BTreeMap, HashMap, VecDeque}, collections::{BTreeMap, HashMap, VecDeque},
fmt, fmt,
rc::Rc,
str::FromStr, str::FromStr,
sync::{ sync::{
atomic::{AtomicBool, Ordering}, atomic::{AtomicBool, Ordering},
@ -488,7 +489,7 @@ impl ClusterQuerySubCommands for App<'_, '_> {
pub fn parse_catchup( pub fn parse_catchup(
matches: &ArgMatches<'_>, matches: &ArgMatches<'_>,
wallet_manager: &mut Option<Arc<RemoteWalletManager>>, wallet_manager: &mut Option<Rc<RemoteWalletManager>>,
) -> Result<CliCommandInfo, CliError> { ) -> Result<CliCommandInfo, CliError> {
let node_pubkey = pubkey_of_signer(matches, "node_pubkey", wallet_manager)?; let node_pubkey = pubkey_of_signer(matches, "node_pubkey", wallet_manager)?;
let mut our_localhost_port = value_t!(matches, "our_localhost", u16).ok(); let mut our_localhost_port = value_t!(matches, "our_localhost", u16).ok();
@ -523,7 +524,7 @@ pub fn parse_catchup(
pub fn parse_cluster_ping( pub fn parse_cluster_ping(
matches: &ArgMatches<'_>, matches: &ArgMatches<'_>,
default_signer: &DefaultSigner, default_signer: &DefaultSigner,
wallet_manager: &mut Option<Arc<RemoteWalletManager>>, wallet_manager: &mut Option<Rc<RemoteWalletManager>>,
) -> Result<CliCommandInfo, CliError> { ) -> Result<CliCommandInfo, CliError> {
let interval = Duration::from_secs(value_t_or_exit!(matches, "interval", u64)); let interval = Duration::from_secs(value_t_or_exit!(matches, "interval", u64));
let count = if matches.is_present("count") { let count = if matches.is_present("count") {
@ -630,7 +631,7 @@ pub fn parse_get_transaction_count(_matches: &ArgMatches<'_>) -> Result<CliComma
pub fn parse_show_stakes( pub fn parse_show_stakes(
matches: &ArgMatches<'_>, matches: &ArgMatches<'_>,
wallet_manager: &mut Option<Arc<RemoteWalletManager>>, wallet_manager: &mut Option<Rc<RemoteWalletManager>>,
) -> Result<CliCommandInfo, CliError> { ) -> Result<CliCommandInfo, CliError> {
let use_lamports_unit = matches.is_present("lamports"); let use_lamports_unit = matches.is_present("lamports");
let vote_account_pubkeys = let vote_account_pubkeys =
@ -682,7 +683,7 @@ pub fn parse_show_validators(matches: &ArgMatches<'_>) -> Result<CliCommandInfo,
pub fn parse_transaction_history( pub fn parse_transaction_history(
matches: &ArgMatches<'_>, matches: &ArgMatches<'_>,
wallet_manager: &mut Option<Arc<RemoteWalletManager>>, wallet_manager: &mut Option<Rc<RemoteWalletManager>>,
) -> Result<CliCommandInfo, CliError> { ) -> Result<CliCommandInfo, CliError> {
let address = pubkey_of_signer(matches, "address", wallet_manager)?.unwrap(); let address = pubkey_of_signer(matches, "address", wallet_manager)?.unwrap();
@ -1581,7 +1582,7 @@ pub fn process_ping(
pub fn parse_logs( pub fn parse_logs(
matches: &ArgMatches<'_>, matches: &ArgMatches<'_>,
wallet_manager: &mut Option<Arc<RemoteWalletManager>>, wallet_manager: &mut Option<Rc<RemoteWalletManager>>,
) -> Result<CliCommandInfo, CliError> { ) -> Result<CliCommandInfo, CliError> {
let address = pubkey_of_signer(matches, "address", wallet_manager)?; let address = pubkey_of_signer(matches, "address", wallet_manager)?;
let include_votes = matches.is_present("include_votes"); let include_votes = matches.is_present("include_votes");

View File

@ -25,7 +25,7 @@ use {
stake_history::Epoch, stake_history::Epoch,
transaction::Transaction, transaction::Transaction,
}, },
std::{cmp::Ordering, collections::HashMap, fmt, str::FromStr, sync::Arc}, std::{cmp::Ordering, collections::HashMap, fmt, rc::Rc, str::FromStr},
}; };
const DEFAULT_MAX_ACTIVE_DISPLAY_AGE_SLOTS: Slot = 15_000_000; // ~90days const DEFAULT_MAX_ACTIVE_DISPLAY_AGE_SLOTS: Slot = 15_000_000; // ~90days
@ -478,7 +478,7 @@ fn known_feature(feature: &Pubkey) -> Result<(), CliError> {
pub fn parse_feature_subcommand( pub fn parse_feature_subcommand(
matches: &ArgMatches<'_>, matches: &ArgMatches<'_>,
default_signer: &DefaultSigner, default_signer: &DefaultSigner,
wallet_manager: &mut Option<Arc<RemoteWalletManager>>, wallet_manager: &mut Option<Rc<RemoteWalletManager>>,
) -> Result<CliCommandInfo, CliError> { ) -> Result<CliCommandInfo, CliError> {
let response = match matches.subcommand() { let response = match matches.subcommand() {
("activate", Some(matches)) => { ("activate", Some(matches)) => {

View File

@ -12,7 +12,7 @@ use {
solana_remote_wallet::remote_wallet::RemoteWalletManager, solana_remote_wallet::remote_wallet::RemoteWalletManager,
solana_rpc_client::rpc_client::RpcClient, solana_rpc_client::rpc_client::RpcClient,
solana_sdk::{clock::Epoch, pubkey::Pubkey}, solana_sdk::{clock::Epoch, pubkey::Pubkey},
std::sync::Arc, std::rc::Rc,
}; };
#[derive(Debug, PartialEq, Eq)] #[derive(Debug, PartialEq, Eq)]
@ -56,7 +56,7 @@ impl InflationSubCommands for App<'_, '_> {
pub fn parse_inflation_subcommand( pub fn parse_inflation_subcommand(
matches: &ArgMatches<'_>, matches: &ArgMatches<'_>,
_default_signer: &DefaultSigner, _default_signer: &DefaultSigner,
_wallet_manager: &mut Option<Arc<RemoteWalletManager>>, _wallet_manager: &mut Option<Rc<RemoteWalletManager>>,
) -> Result<CliCommandInfo, CliError> { ) -> Result<CliCommandInfo, CliError> {
let command = match matches.subcommand() { let command = match matches.subcommand() {
("rewards", Some(matches)) => { ("rewards", Some(matches)) => {

View File

@ -18,7 +18,7 @@ use {
solana_remote_wallet::remote_wallet::RemoteWalletManager, solana_remote_wallet::remote_wallet::RemoteWalletManager,
solana_rpc_client_api::config::RpcSendTransactionConfig, solana_rpc_client_api::config::RpcSendTransactionConfig,
solana_tpu_client::tpu_client::DEFAULT_TPU_ENABLE_UDP, solana_tpu_client::tpu_client::DEFAULT_TPU_ENABLE_UDP,
std::{collections::HashMap, error, path::PathBuf, sync::Arc, time::Duration}, std::{collections::HashMap, error, path::PathBuf, rc::Rc, time::Duration},
}; };
fn parse_settings(matches: &ArgMatches<'_>) -> Result<bool, Box<dyn error::Error>> { fn parse_settings(matches: &ArgMatches<'_>) -> Result<bool, Box<dyn error::Error>> {
@ -142,7 +142,7 @@ fn parse_settings(matches: &ArgMatches<'_>) -> Result<bool, Box<dyn error::Error
pub fn parse_args<'a>( pub fn parse_args<'a>(
matches: &ArgMatches<'_>, matches: &ArgMatches<'_>,
wallet_manager: &mut Option<Arc<RemoteWalletManager>>, wallet_manager: &mut Option<Rc<RemoteWalletManager>>,
) -> Result<(CliConfig<'a>, CliSigners), Box<dyn error::Error>> { ) -> Result<(CliConfig<'a>, CliSigners), Box<dyn error::Error>> {
let config = if let Some(config_file) = matches.value_of("config_file") { let config = if let Some(config_file) = matches.value_of("config_file") {
Config::load(config_file).unwrap_or_default() Config::load(config_file).unwrap_or_default()

View File

@ -36,7 +36,7 @@ use {
system_program, system_program,
transaction::Transaction, transaction::Transaction,
}, },
std::sync::Arc, std::rc::Rc,
}; };
pub trait NonceSubCommands { pub trait NonceSubCommands {
@ -197,7 +197,7 @@ impl NonceSubCommands for App<'_, '_> {
pub fn parse_authorize_nonce_account( pub fn parse_authorize_nonce_account(
matches: &ArgMatches<'_>, matches: &ArgMatches<'_>,
default_signer: &DefaultSigner, default_signer: &DefaultSigner,
wallet_manager: &mut Option<Arc<RemoteWalletManager>>, wallet_manager: &mut Option<Rc<RemoteWalletManager>>,
) -> Result<CliCommandInfo, CliError> { ) -> Result<CliCommandInfo, CliError> {
let nonce_account = pubkey_of_signer(matches, "nonce_account_pubkey", wallet_manager)?.unwrap(); let nonce_account = pubkey_of_signer(matches, "nonce_account_pubkey", wallet_manager)?.unwrap();
let new_authority = pubkey_of_signer(matches, "new_authority", wallet_manager)?.unwrap(); let new_authority = pubkey_of_signer(matches, "new_authority", wallet_manager)?.unwrap();
@ -228,7 +228,7 @@ pub fn parse_authorize_nonce_account(
pub fn parse_nonce_create_account( pub fn parse_nonce_create_account(
matches: &ArgMatches<'_>, matches: &ArgMatches<'_>,
default_signer: &DefaultSigner, default_signer: &DefaultSigner,
wallet_manager: &mut Option<Arc<RemoteWalletManager>>, wallet_manager: &mut Option<Rc<RemoteWalletManager>>,
) -> Result<CliCommandInfo, CliError> { ) -> Result<CliCommandInfo, CliError> {
let (nonce_account, nonce_account_pubkey) = let (nonce_account, nonce_account_pubkey) =
signer_of(matches, "nonce_account_keypair", wallet_manager)?; signer_of(matches, "nonce_account_keypair", wallet_manager)?;
@ -260,7 +260,7 @@ pub fn parse_nonce_create_account(
pub fn parse_get_nonce( pub fn parse_get_nonce(
matches: &ArgMatches<'_>, matches: &ArgMatches<'_>,
wallet_manager: &mut Option<Arc<RemoteWalletManager>>, wallet_manager: &mut Option<Rc<RemoteWalletManager>>,
) -> Result<CliCommandInfo, CliError> { ) -> Result<CliCommandInfo, CliError> {
let nonce_account_pubkey = let nonce_account_pubkey =
pubkey_of_signer(matches, "nonce_account_pubkey", wallet_manager)?.unwrap(); pubkey_of_signer(matches, "nonce_account_pubkey", wallet_manager)?.unwrap();
@ -274,7 +274,7 @@ pub fn parse_get_nonce(
pub fn parse_new_nonce( pub fn parse_new_nonce(
matches: &ArgMatches<'_>, matches: &ArgMatches<'_>,
default_signer: &DefaultSigner, default_signer: &DefaultSigner,
wallet_manager: &mut Option<Arc<RemoteWalletManager>>, wallet_manager: &mut Option<Rc<RemoteWalletManager>>,
) -> Result<CliCommandInfo, CliError> { ) -> Result<CliCommandInfo, CliError> {
let nonce_account = pubkey_of_signer(matches, "nonce_account_pubkey", wallet_manager)?.unwrap(); let nonce_account = pubkey_of_signer(matches, "nonce_account_pubkey", wallet_manager)?.unwrap();
let memo = matches.value_of(MEMO_ARG.name).map(String::from); let memo = matches.value_of(MEMO_ARG.name).map(String::from);
@ -302,7 +302,7 @@ pub fn parse_new_nonce(
pub fn parse_show_nonce_account( pub fn parse_show_nonce_account(
matches: &ArgMatches<'_>, matches: &ArgMatches<'_>,
wallet_manager: &mut Option<Arc<RemoteWalletManager>>, wallet_manager: &mut Option<Rc<RemoteWalletManager>>,
) -> Result<CliCommandInfo, CliError> { ) -> Result<CliCommandInfo, CliError> {
let nonce_account_pubkey = let nonce_account_pubkey =
pubkey_of_signer(matches, "nonce_account_pubkey", wallet_manager)?.unwrap(); pubkey_of_signer(matches, "nonce_account_pubkey", wallet_manager)?.unwrap();
@ -320,7 +320,7 @@ pub fn parse_show_nonce_account(
pub fn parse_withdraw_from_nonce_account( pub fn parse_withdraw_from_nonce_account(
matches: &ArgMatches<'_>, matches: &ArgMatches<'_>,
default_signer: &DefaultSigner, default_signer: &DefaultSigner,
wallet_manager: &mut Option<Arc<RemoteWalletManager>>, wallet_manager: &mut Option<Rc<RemoteWalletManager>>,
) -> Result<CliCommandInfo, CliError> { ) -> Result<CliCommandInfo, CliError> {
let nonce_account = pubkey_of_signer(matches, "nonce_account_pubkey", wallet_manager)?.unwrap(); let nonce_account = pubkey_of_signer(matches, "nonce_account_pubkey", wallet_manager)?.unwrap();
let destination_account_pubkey = let destination_account_pubkey =

View File

@ -60,6 +60,7 @@ use {
io::{Read, Write}, io::{Read, Write},
mem::size_of, mem::size_of,
path::PathBuf, path::PathBuf,
rc::Rc,
str::FromStr, str::FromStr,
sync::Arc, sync::Arc,
}, },
@ -431,7 +432,7 @@ impl ProgramSubCommands for App<'_, '_> {
pub fn parse_program_subcommand( pub fn parse_program_subcommand(
matches: &ArgMatches<'_>, matches: &ArgMatches<'_>,
default_signer: &DefaultSigner, default_signer: &DefaultSigner,
wallet_manager: &mut Option<Arc<RemoteWalletManager>>, wallet_manager: &mut Option<Rc<RemoteWalletManager>>,
) -> Result<CliCommandInfo, CliError> { ) -> Result<CliCommandInfo, CliError> {
let (subcommand, sub_matches) = matches.subcommand(); let (subcommand, sub_matches) = matches.subcommand();
let matches_skip_fee_check = matches.is_present("skip_fee_check"); let matches_skip_fee_check = matches.is_present("skip_fee_check");

View File

@ -59,7 +59,7 @@ use {
sysvar::{clock, stake_history}, sysvar::{clock, stake_history},
transaction::Transaction, transaction::Transaction,
}, },
std::{ops::Deref, sync::Arc}, std::{ops::Deref, rc::Rc},
}; };
pub const STAKE_AUTHORITY_ARG: ArgConstant<'static> = ArgConstant { pub const STAKE_AUTHORITY_ARG: ArgConstant<'static> = ArgConstant {
@ -740,7 +740,7 @@ impl StakeSubCommands for App<'_, '_> {
pub fn parse_create_stake_account( pub fn parse_create_stake_account(
matches: &ArgMatches<'_>, matches: &ArgMatches<'_>,
default_signer: &DefaultSigner, default_signer: &DefaultSigner,
wallet_manager: &mut Option<Arc<RemoteWalletManager>>, wallet_manager: &mut Option<Rc<RemoteWalletManager>>,
checked: bool, checked: bool,
) -> Result<CliCommandInfo, CliError> { ) -> Result<CliCommandInfo, CliError> {
let seed = matches.value_of("seed").map(|s| s.to_string()); let seed = matches.value_of("seed").map(|s| s.to_string());
@ -816,7 +816,7 @@ pub fn parse_create_stake_account(
pub fn parse_stake_delegate_stake( pub fn parse_stake_delegate_stake(
matches: &ArgMatches<'_>, matches: &ArgMatches<'_>,
default_signer: &DefaultSigner, default_signer: &DefaultSigner,
wallet_manager: &mut Option<Arc<RemoteWalletManager>>, wallet_manager: &mut Option<Rc<RemoteWalletManager>>,
) -> Result<CliCommandInfo, CliError> { ) -> Result<CliCommandInfo, CliError> {
let stake_account_pubkey = let stake_account_pubkey =
pubkey_of_signer(matches, "stake_account_pubkey", wallet_manager)?.unwrap(); pubkey_of_signer(matches, "stake_account_pubkey", wallet_manager)?.unwrap();
@ -871,7 +871,7 @@ pub fn parse_stake_delegate_stake(
pub fn parse_stake_authorize( pub fn parse_stake_authorize(
matches: &ArgMatches<'_>, matches: &ArgMatches<'_>,
default_signer: &DefaultSigner, default_signer: &DefaultSigner,
wallet_manager: &mut Option<Arc<RemoteWalletManager>>, wallet_manager: &mut Option<Rc<RemoteWalletManager>>,
checked: bool, checked: bool,
) -> Result<CliCommandInfo, CliError> { ) -> Result<CliCommandInfo, CliError> {
let stake_account_pubkey = let stake_account_pubkey =
@ -1000,7 +1000,7 @@ pub fn parse_stake_authorize(
pub fn parse_split_stake( pub fn parse_split_stake(
matches: &ArgMatches<'_>, matches: &ArgMatches<'_>,
default_signer: &DefaultSigner, default_signer: &DefaultSigner,
wallet_manager: &mut Option<Arc<RemoteWalletManager>>, wallet_manager: &mut Option<Rc<RemoteWalletManager>>,
) -> Result<CliCommandInfo, CliError> { ) -> Result<CliCommandInfo, CliError> {
let stake_account_pubkey = let stake_account_pubkey =
pubkey_of_signer(matches, "stake_account_pubkey", wallet_manager)?.unwrap(); pubkey_of_signer(matches, "stake_account_pubkey", wallet_manager)?.unwrap();
@ -1051,7 +1051,7 @@ pub fn parse_split_stake(
pub fn parse_merge_stake( pub fn parse_merge_stake(
matches: &ArgMatches<'_>, matches: &ArgMatches<'_>,
default_signer: &DefaultSigner, default_signer: &DefaultSigner,
wallet_manager: &mut Option<Arc<RemoteWalletManager>>, wallet_manager: &mut Option<Rc<RemoteWalletManager>>,
) -> Result<CliCommandInfo, CliError> { ) -> Result<CliCommandInfo, CliError> {
let stake_account_pubkey = let stake_account_pubkey =
pubkey_of_signer(matches, "stake_account_pubkey", wallet_manager)?.unwrap(); pubkey_of_signer(matches, "stake_account_pubkey", wallet_manager)?.unwrap();
@ -1098,7 +1098,7 @@ pub fn parse_merge_stake(
pub fn parse_stake_deactivate_stake( pub fn parse_stake_deactivate_stake(
matches: &ArgMatches<'_>, matches: &ArgMatches<'_>,
default_signer: &DefaultSigner, default_signer: &DefaultSigner,
wallet_manager: &mut Option<Arc<RemoteWalletManager>>, wallet_manager: &mut Option<Rc<RemoteWalletManager>>,
) -> Result<CliCommandInfo, CliError> { ) -> Result<CliCommandInfo, CliError> {
let stake_account_pubkey = let stake_account_pubkey =
pubkey_of_signer(matches, "stake_account_pubkey", wallet_manager)?.unwrap(); pubkey_of_signer(matches, "stake_account_pubkey", wallet_manager)?.unwrap();
@ -1146,7 +1146,7 @@ pub fn parse_stake_deactivate_stake(
pub fn parse_stake_withdraw_stake( pub fn parse_stake_withdraw_stake(
matches: &ArgMatches<'_>, matches: &ArgMatches<'_>,
default_signer: &DefaultSigner, default_signer: &DefaultSigner,
wallet_manager: &mut Option<Arc<RemoteWalletManager>>, wallet_manager: &mut Option<Rc<RemoteWalletManager>>,
) -> Result<CliCommandInfo, CliError> { ) -> Result<CliCommandInfo, CliError> {
let stake_account_pubkey = let stake_account_pubkey =
pubkey_of_signer(matches, "stake_account_pubkey", wallet_manager)?.unwrap(); pubkey_of_signer(matches, "stake_account_pubkey", wallet_manager)?.unwrap();
@ -1201,7 +1201,7 @@ pub fn parse_stake_withdraw_stake(
pub fn parse_stake_set_lockup( pub fn parse_stake_set_lockup(
matches: &ArgMatches<'_>, matches: &ArgMatches<'_>,
default_signer: &DefaultSigner, default_signer: &DefaultSigner,
wallet_manager: &mut Option<Arc<RemoteWalletManager>>, wallet_manager: &mut Option<Rc<RemoteWalletManager>>,
checked: bool, checked: bool,
) -> Result<CliCommandInfo, CliError> { ) -> Result<CliCommandInfo, CliError> {
let stake_account_pubkey = let stake_account_pubkey =
@ -1269,7 +1269,7 @@ pub fn parse_stake_set_lockup(
pub fn parse_show_stake_account( pub fn parse_show_stake_account(
matches: &ArgMatches<'_>, matches: &ArgMatches<'_>,
wallet_manager: &mut Option<Arc<RemoteWalletManager>>, wallet_manager: &mut Option<Rc<RemoteWalletManager>>,
) -> Result<CliCommandInfo, CliError> { ) -> Result<CliCommandInfo, CliError> {
let stake_account_pubkey = let stake_account_pubkey =
pubkey_of_signer(matches, "stake_account_pubkey", wallet_manager)?.unwrap(); pubkey_of_signer(matches, "stake_account_pubkey", wallet_manager)?.unwrap();

View File

@ -27,7 +27,7 @@ use {
signature::{Keypair, Signer}, signature::{Keypair, Signer},
transaction::Transaction, transaction::Transaction,
}, },
std::{error, sync::Arc}, std::{error, rc::Rc},
}; };
// Return an error if a validator details are longer than the max length. // Return an error if a validator details are longer than the max length.
@ -233,7 +233,7 @@ impl ValidatorInfoSubCommands for App<'_, '_> {
pub fn parse_validator_info_command( pub fn parse_validator_info_command(
matches: &ArgMatches<'_>, matches: &ArgMatches<'_>,
default_signer: &DefaultSigner, default_signer: &DefaultSigner,
wallet_manager: &mut Option<Arc<RemoteWalletManager>>, wallet_manager: &mut Option<Rc<RemoteWalletManager>>,
) -> Result<CliCommandInfo, CliError> { ) -> Result<CliCommandInfo, CliError> {
let info_pubkey = pubkey_of(matches, "info_pubkey"); let info_pubkey = pubkey_of(matches, "info_pubkey");
// Prepare validator info // Prepare validator info

View File

@ -40,7 +40,7 @@ use {
vote_instruction::{self, withdraw, CreateVoteAccountConfig}, vote_instruction::{self, withdraw, CreateVoteAccountConfig},
vote_state::{VoteAuthorize, VoteInit, VoteState, VoteStateVersions}, vote_state::{VoteAuthorize, VoteInit, VoteState, VoteStateVersions},
}, },
std::sync::Arc, std::rc::Rc,
}; };
pub trait VoteSubCommands { pub trait VoteSubCommands {
@ -421,7 +421,7 @@ impl VoteSubCommands for App<'_, '_> {
pub fn parse_create_vote_account( pub fn parse_create_vote_account(
matches: &ArgMatches<'_>, matches: &ArgMatches<'_>,
default_signer: &DefaultSigner, default_signer: &DefaultSigner,
wallet_manager: &mut Option<Arc<RemoteWalletManager>>, wallet_manager: &mut Option<Rc<RemoteWalletManager>>,
) -> Result<CliCommandInfo, CliError> { ) -> Result<CliCommandInfo, CliError> {
let (vote_account, vote_account_pubkey) = signer_of(matches, "vote_account", wallet_manager)?; let (vote_account, vote_account_pubkey) = signer_of(matches, "vote_account", wallet_manager)?;
let seed = matches.value_of("seed").map(|s| s.to_string()); let seed = matches.value_of("seed").map(|s| s.to_string());
@ -490,7 +490,7 @@ pub fn parse_create_vote_account(
pub fn parse_vote_authorize( pub fn parse_vote_authorize(
matches: &ArgMatches<'_>, matches: &ArgMatches<'_>,
default_signer: &DefaultSigner, default_signer: &DefaultSigner,
wallet_manager: &mut Option<Arc<RemoteWalletManager>>, wallet_manager: &mut Option<Rc<RemoteWalletManager>>,
vote_authorize: VoteAuthorize, vote_authorize: VoteAuthorize,
checked: bool, checked: bool,
) -> Result<CliCommandInfo, CliError> { ) -> Result<CliCommandInfo, CliError> {
@ -551,7 +551,7 @@ pub fn parse_vote_authorize(
pub fn parse_vote_update_validator( pub fn parse_vote_update_validator(
matches: &ArgMatches<'_>, matches: &ArgMatches<'_>,
default_signer: &DefaultSigner, default_signer: &DefaultSigner,
wallet_manager: &mut Option<Arc<RemoteWalletManager>>, wallet_manager: &mut Option<Rc<RemoteWalletManager>>,
) -> Result<CliCommandInfo, CliError> { ) -> Result<CliCommandInfo, CliError> {
let vote_account_pubkey = let vote_account_pubkey =
pubkey_of_signer(matches, "vote_account_pubkey", wallet_manager)?.unwrap(); pubkey_of_signer(matches, "vote_account_pubkey", wallet_manager)?.unwrap();
@ -598,7 +598,7 @@ pub fn parse_vote_update_validator(
pub fn parse_vote_update_commission( pub fn parse_vote_update_commission(
matches: &ArgMatches<'_>, matches: &ArgMatches<'_>,
default_signer: &DefaultSigner, default_signer: &DefaultSigner,
wallet_manager: &mut Option<Arc<RemoteWalletManager>>, wallet_manager: &mut Option<Rc<RemoteWalletManager>>,
) -> Result<CliCommandInfo, CliError> { ) -> Result<CliCommandInfo, CliError> {
let vote_account_pubkey = let vote_account_pubkey =
pubkey_of_signer(matches, "vote_account_pubkey", wallet_manager)?.unwrap(); pubkey_of_signer(matches, "vote_account_pubkey", wallet_manager)?.unwrap();
@ -643,7 +643,7 @@ pub fn parse_vote_update_commission(
pub fn parse_vote_get_account_command( pub fn parse_vote_get_account_command(
matches: &ArgMatches<'_>, matches: &ArgMatches<'_>,
wallet_manager: &mut Option<Arc<RemoteWalletManager>>, wallet_manager: &mut Option<Rc<RemoteWalletManager>>,
) -> Result<CliCommandInfo, CliError> { ) -> Result<CliCommandInfo, CliError> {
let vote_account_pubkey = let vote_account_pubkey =
pubkey_of_signer(matches, "vote_account_pubkey", wallet_manager)?.unwrap(); pubkey_of_signer(matches, "vote_account_pubkey", wallet_manager)?.unwrap();
@ -666,7 +666,7 @@ pub fn parse_vote_get_account_command(
pub fn parse_withdraw_from_vote_account( pub fn parse_withdraw_from_vote_account(
matches: &ArgMatches<'_>, matches: &ArgMatches<'_>,
default_signer: &DefaultSigner, default_signer: &DefaultSigner,
wallet_manager: &mut Option<Arc<RemoteWalletManager>>, wallet_manager: &mut Option<Rc<RemoteWalletManager>>,
) -> Result<CliCommandInfo, CliError> { ) -> Result<CliCommandInfo, CliError> {
let vote_account_pubkey = let vote_account_pubkey =
pubkey_of_signer(matches, "vote_account_pubkey", wallet_manager)?.unwrap(); pubkey_of_signer(matches, "vote_account_pubkey", wallet_manager)?.unwrap();
@ -722,7 +722,7 @@ pub fn parse_withdraw_from_vote_account(
pub fn parse_close_vote_account( pub fn parse_close_vote_account(
matches: &ArgMatches<'_>, matches: &ArgMatches<'_>,
default_signer: &DefaultSigner, default_signer: &DefaultSigner,
wallet_manager: &mut Option<Arc<RemoteWalletManager>>, wallet_manager: &mut Option<Rc<RemoteWalletManager>>,
) -> Result<CliCommandInfo, CliError> { ) -> Result<CliCommandInfo, CliError> {
let vote_account_pubkey = let vote_account_pubkey =
pubkey_of_signer(matches, "vote_account_pubkey", wallet_manager)?.unwrap(); pubkey_of_signer(matches, "vote_account_pubkey", wallet_manager)?.unwrap();

View File

@ -47,7 +47,7 @@ use {
EncodableWithMeta, EncodedConfirmedTransactionWithStatusMeta, EncodedTransaction, EncodableWithMeta, EncodedConfirmedTransactionWithStatusMeta, EncodedTransaction,
TransactionBinaryEncoding, UiTransactionEncoding, TransactionBinaryEncoding, UiTransactionEncoding,
}, },
std::{fmt::Write as FmtWrite, fs::File, io::Write, str::FromStr, sync::Arc}, std::{fmt::Write as FmtWrite, fs::File, io::Write, rc::Rc, str::FromStr},
}; };
pub trait WalletSubCommands { pub trait WalletSubCommands {
@ -393,7 +393,7 @@ fn resolve_derived_address_program_id(matches: &ArgMatches<'_>, arg_name: &str)
pub fn parse_account( pub fn parse_account(
matches: &ArgMatches<'_>, matches: &ArgMatches<'_>,
wallet_manager: &mut Option<Arc<RemoteWalletManager>>, wallet_manager: &mut Option<Rc<RemoteWalletManager>>,
) -> Result<CliCommandInfo, CliError> { ) -> Result<CliCommandInfo, CliError> {
let account_pubkey = pubkey_of_signer(matches, "account_pubkey", wallet_manager)?.unwrap(); let account_pubkey = pubkey_of_signer(matches, "account_pubkey", wallet_manager)?.unwrap();
let output_file = matches.value_of("output_file"); let output_file = matches.value_of("output_file");
@ -411,7 +411,7 @@ pub fn parse_account(
pub fn parse_airdrop( pub fn parse_airdrop(
matches: &ArgMatches<'_>, matches: &ArgMatches<'_>,
default_signer: &DefaultSigner, default_signer: &DefaultSigner,
wallet_manager: &mut Option<Arc<RemoteWalletManager>>, wallet_manager: &mut Option<Rc<RemoteWalletManager>>,
) -> Result<CliCommandInfo, CliError> { ) -> Result<CliCommandInfo, CliError> {
let pubkey = pubkey_of_signer(matches, "to", wallet_manager)?; let pubkey = pubkey_of_signer(matches, "to", wallet_manager)?;
let signers = if pubkey.is_some() { let signers = if pubkey.is_some() {
@ -429,7 +429,7 @@ pub fn parse_airdrop(
pub fn parse_balance( pub fn parse_balance(
matches: &ArgMatches<'_>, matches: &ArgMatches<'_>,
default_signer: &DefaultSigner, default_signer: &DefaultSigner,
wallet_manager: &mut Option<Arc<RemoteWalletManager>>, wallet_manager: &mut Option<Rc<RemoteWalletManager>>,
) -> Result<CliCommandInfo, CliError> { ) -> Result<CliCommandInfo, CliError> {
let pubkey = pubkey_of_signer(matches, "pubkey", wallet_manager)?; let pubkey = pubkey_of_signer(matches, "pubkey", wallet_manager)?;
let signers = if pubkey.is_some() { let signers = if pubkey.is_some() {
@ -470,7 +470,7 @@ pub fn parse_decode_transaction(matches: &ArgMatches<'_>) -> Result<CliCommandIn
pub fn parse_create_address_with_seed( pub fn parse_create_address_with_seed(
matches: &ArgMatches<'_>, matches: &ArgMatches<'_>,
default_signer: &DefaultSigner, default_signer: &DefaultSigner,
wallet_manager: &mut Option<Arc<RemoteWalletManager>>, wallet_manager: &mut Option<Rc<RemoteWalletManager>>,
) -> Result<CliCommandInfo, CliError> { ) -> Result<CliCommandInfo, CliError> {
let from_pubkey = pubkey_of_signer(matches, "from", wallet_manager)?; let from_pubkey = pubkey_of_signer(matches, "from", wallet_manager)?;
let signers = if from_pubkey.is_some() { let signers = if from_pubkey.is_some() {
@ -542,7 +542,7 @@ pub fn parse_find_program_derived_address(
pub fn parse_transfer( pub fn parse_transfer(
matches: &ArgMatches<'_>, matches: &ArgMatches<'_>,
default_signer: &DefaultSigner, default_signer: &DefaultSigner,
wallet_manager: &mut Option<Arc<RemoteWalletManager>>, wallet_manager: &mut Option<Rc<RemoteWalletManager>>,
) -> Result<CliCommandInfo, CliError> { ) -> Result<CliCommandInfo, CliError> {
let amount = SpendAmount::new_from_matches(matches, "amount"); let amount = SpendAmount::new_from_matches(matches, "amount");
let to = pubkey_of_signer(matches, "to", wallet_manager)?.unwrap(); let to = pubkey_of_signer(matches, "to", wallet_manager)?.unwrap();
@ -598,7 +598,7 @@ pub fn parse_transfer(
pub fn parse_sign_offchain_message( pub fn parse_sign_offchain_message(
matches: &ArgMatches<'_>, matches: &ArgMatches<'_>,
default_signer: &DefaultSigner, default_signer: &DefaultSigner,
wallet_manager: &mut Option<Arc<RemoteWalletManager>>, wallet_manager: &mut Option<Rc<RemoteWalletManager>>,
) -> Result<CliCommandInfo, CliError> { ) -> Result<CliCommandInfo, CliError> {
let version: u8 = value_of(matches, "version").unwrap(); let version: u8 = value_of(matches, "version").unwrap();
let message_text: String = value_of(matches, "message") let message_text: String = value_of(matches, "message")
@ -615,7 +615,7 @@ pub fn parse_sign_offchain_message(
pub fn parse_verify_offchain_signature( pub fn parse_verify_offchain_signature(
matches: &ArgMatches<'_>, matches: &ArgMatches<'_>,
default_signer: &DefaultSigner, default_signer: &DefaultSigner,
wallet_manager: &mut Option<Arc<RemoteWalletManager>>, wallet_manager: &mut Option<Rc<RemoteWalletManager>>,
) -> Result<CliCommandInfo, CliError> { ) -> Result<CliCommandInfo, CliError> {
let version: u8 = value_of(matches, "version").unwrap(); let version: u8 = value_of(matches, "version").unwrap();
let message_text: String = value_of(matches, "message") let message_text: String = value_of(matches, "message")

View File

@ -34,6 +34,7 @@ use {
std::{ std::{
collections::HashSet, collections::HashSet,
error, error,
rc::Rc,
sync::{ sync::{
atomic::{AtomicBool, AtomicU64, Ordering}, atomic::{AtomicBool, AtomicU64, Ordering},
Arc, Arc,
@ -64,7 +65,7 @@ struct GrindMatch {
fn get_keypair_from_matches( fn get_keypair_from_matches(
matches: &ArgMatches, matches: &ArgMatches,
config: Config, config: Config,
wallet_manager: &mut Option<Arc<RemoteWalletManager>>, wallet_manager: &mut Option<Rc<RemoteWalletManager>>,
) -> Result<Box<dyn Signer>, Box<dyn error::Error>> { ) -> Result<Box<dyn Signer>, Box<dyn error::Error>> {
let mut path = dirs_next::home_dir().expect("home directory"); let mut path = dirs_next::home_dir().expect("home directory");
let path = if matches.is_present("keypair") { let path = if matches.is_present("keypair") {

View File

@ -199,7 +199,7 @@ pub fn create_vm<'a, 'b>(
) -> Result<EbpfVm<'a, InvokeContext<'b>>, Box<dyn std::error::Error>> { ) -> Result<EbpfVm<'a, InvokeContext<'b>>, Box<dyn std::error::Error>> {
let stack_size = stack.len(); let stack_size = stack.len();
let heap_size = heap.len(); let heap_size = heap.len();
let accounts = Arc::clone(invoke_context.transaction_context.accounts()); let accounts = Rc::clone(invoke_context.transaction_context.accounts());
let memory_mapping = create_memory_mapping( let memory_mapping = create_memory_mapping(
program, program,
stack, stack,

View File

@ -6,7 +6,7 @@ use {
dialoguer::{theme::ColorfulTheme, Select}, dialoguer::{theme::ColorfulTheme, Select},
semver::Version as FirmwareVersion, semver::Version as FirmwareVersion,
solana_sdk::derivation_path::DerivationPath, solana_sdk::derivation_path::DerivationPath,
std::{fmt, sync::Arc}, std::{fmt, rc::Rc},
}; };
#[cfg(feature = "hidapi")] #[cfg(feature = "hidapi")]
use { use {
@ -592,7 +592,7 @@ pub fn get_ledger_from_info(
info: RemoteWalletInfo, info: RemoteWalletInfo,
keypair_name: &str, keypair_name: &str,
wallet_manager: &RemoteWalletManager, wallet_manager: &RemoteWalletManager,
) -> Result<Arc<LedgerWallet>, RemoteWalletError> { ) -> Result<Rc<LedgerWallet>, RemoteWalletError> {
let devices = wallet_manager.list_devices(); let devices = wallet_manager.list_devices();
let mut matches = devices let mut matches = devices
.iter() .iter()

View File

@ -1,5 +1,5 @@
#[cfg(feature = "hidapi")] #[cfg(feature = "hidapi")]
use {crate::ledger::is_valid_ledger, parking_lot::Mutex}; use {crate::ledger::is_valid_ledger, parking_lot::Mutex, std::sync::Arc};
use { use {
crate::{ crate::{
ledger::LedgerWallet, ledger::LedgerWallet,
@ -14,7 +14,7 @@ use {
signature::{Signature, SignerError}, signature::{Signature, SignerError},
}, },
std::{ std::{
sync::Arc, rc::Rc,
time::{Duration, Instant}, time::{Duration, Instant},
}, },
thiserror::Error, thiserror::Error,
@ -98,8 +98,8 @@ pub struct RemoteWalletManager {
impl RemoteWalletManager { impl RemoteWalletManager {
/// Create a new instance. /// Create a new instance.
#[cfg(feature = "hidapi")] #[cfg(feature = "hidapi")]
pub fn new(usb: Arc<Mutex<hidapi::HidApi>>) -> Arc<Self> { pub fn new(usb: Arc<Mutex<hidapi::HidApi>>) -> Rc<Self> {
Arc::new(Self { Rc::new(Self {
usb, usb,
devices: RwLock::new(Vec::new()), devices: RwLock::new(Vec::new()),
}) })
@ -132,7 +132,7 @@ impl RemoteWalletManager {
detected_devices.push(Device { detected_devices.push(Device {
path, path,
info, info,
wallet_type: RemoteWalletType::Ledger(Arc::new(ledger)), wallet_type: RemoteWalletType::Ledger(Rc::new(ledger)),
}) })
} }
Err(err) => { Err(err) => {
@ -172,7 +172,7 @@ impl RemoteWalletManager {
pub fn get_ledger( pub fn get_ledger(
&self, &self,
host_device_path: &str, host_device_path: &str,
) -> Result<Arc<LedgerWallet>, RemoteWalletError> { ) -> Result<Rc<LedgerWallet>, RemoteWalletError> {
self.devices self.devices
.read() .read()
.iter() .iter()
@ -261,7 +261,7 @@ pub struct Device {
/// Remote wallet convenience enum to hold various wallet types /// Remote wallet convenience enum to hold various wallet types
#[derive(Debug)] #[derive(Debug)]
pub enum RemoteWalletType { pub enum RemoteWalletType {
Ledger(Arc<LedgerWallet>), Ledger(Rc<LedgerWallet>),
} }
/// Remote wallet information. /// Remote wallet information.
@ -309,18 +309,18 @@ pub fn is_valid_hid_device(usage_page: u16, interface_number: i32) -> bool {
/// Helper to initialize hidapi and RemoteWalletManager /// Helper to initialize hidapi and RemoteWalletManager
#[cfg(feature = "hidapi")] #[cfg(feature = "hidapi")]
pub fn initialize_wallet_manager() -> Result<Arc<RemoteWalletManager>, RemoteWalletError> { pub fn initialize_wallet_manager() -> Result<Rc<RemoteWalletManager>, RemoteWalletError> {
let hidapi = Arc::new(Mutex::new(hidapi::HidApi::new()?)); let hidapi = Arc::new(Mutex::new(hidapi::HidApi::new()?));
Ok(RemoteWalletManager::new(hidapi)) Ok(RemoteWalletManager::new(hidapi))
} }
#[cfg(not(feature = "hidapi"))] #[cfg(not(feature = "hidapi"))]
pub fn initialize_wallet_manager() -> Result<Arc<RemoteWalletManager>, RemoteWalletError> { pub fn initialize_wallet_manager() -> Result<Rc<RemoteWalletManager>, RemoteWalletError> {
Err(RemoteWalletError::Hid( Err(RemoteWalletError::Hid(
"hidapi crate compilation disabled in solana-remote-wallet.".to_string(), "hidapi crate compilation disabled in solana-remote-wallet.".to_string(),
)) ))
} }
pub fn maybe_wallet_manager() -> Result<Option<Arc<RemoteWalletManager>>, RemoteWalletError> { pub fn maybe_wallet_manager() -> Result<Option<Rc<RemoteWalletManager>>, RemoteWalletError> {
let wallet_manager = initialize_wallet_manager()?; let wallet_manager = initialize_wallet_manager()?;
let device_count = wallet_manager.update_devices()?; let device_count = wallet_manager.update_devices()?;
if device_count > 0 { if device_count > 0 {

View File

@ -25,7 +25,7 @@ use {
cell::{Ref, RefCell, RefMut}, cell::{Ref, RefCell, RefMut},
collections::HashSet, collections::HashSet,
pin::Pin, pin::Pin,
sync::Arc, rc::Rc,
}, },
}; };
@ -142,7 +142,7 @@ impl TransactionAccounts {
#[derive(Debug, Clone, PartialEq)] #[derive(Debug, Clone, PartialEq)]
pub struct TransactionContext { pub struct TransactionContext {
account_keys: Pin<Box<[Pubkey]>>, account_keys: Pin<Box<[Pubkey]>>,
accounts: Arc<TransactionAccounts>, accounts: Rc<TransactionAccounts>,
instruction_stack_capacity: usize, instruction_stack_capacity: usize,
instruction_trace_capacity: usize, instruction_trace_capacity: usize,
instruction_stack: Vec<usize>, instruction_stack: Vec<usize>,
@ -173,7 +173,7 @@ impl TransactionContext {
.unzip(); .unzip();
Self { Self {
account_keys: Pin::new(account_keys.into_boxed_slice()), account_keys: Pin::new(account_keys.into_boxed_slice()),
accounts: Arc::new(TransactionAccounts::new(accounts, rent.is_some())), accounts: Rc::new(TransactionAccounts::new(accounts, rent.is_some())),
instruction_stack_capacity, instruction_stack_capacity,
instruction_trace_capacity, instruction_trace_capacity,
instruction_stack: Vec::with_capacity(instruction_stack_capacity), instruction_stack: Vec::with_capacity(instruction_stack_capacity),
@ -194,13 +194,13 @@ impl TransactionContext {
return Err(InstructionError::CallDepth); return Err(InstructionError::CallDepth);
} }
Ok(Arc::try_unwrap(self.accounts) Ok(Rc::try_unwrap(self.accounts)
.expect("transaction_context.accounts has unexpected outstanding refs") .expect("transaction_context.accounts has unexpected outstanding refs")
.into_accounts()) .into_accounts())
} }
#[cfg(not(target_os = "solana"))] #[cfg(not(target_os = "solana"))]
pub fn accounts(&self) -> &Arc<TransactionAccounts> { pub fn accounts(&self) -> &Rc<TransactionAccounts> {
&self.accounts &self.accounts
} }
@ -1208,7 +1208,7 @@ pub struct ExecutionRecord {
#[cfg(not(target_os = "solana"))] #[cfg(not(target_os = "solana"))]
impl From<TransactionContext> for ExecutionRecord { impl From<TransactionContext> for ExecutionRecord {
fn from(context: TransactionContext) -> Self { fn from(context: TransactionContext) -> Self {
let accounts = Arc::try_unwrap(context.accounts) let accounts = Rc::try_unwrap(context.accounts)
.expect("transaction_context.accounts has unexpectd outstanding refs"); .expect("transaction_context.accounts has unexpectd outstanding refs");
let touched_account_count = accounts.touched_count() as u64; let touched_account_count = accounts.touched_count() as u64;
let accounts = accounts.into_accounts(); let accounts = accounts.into_accounts();

View File

@ -7,7 +7,7 @@ use {
pubkey::Pubkey, pubkey::Pubkey,
signature::Signer, signature::Signer,
}, },
std::{error::Error, sync::Arc}, std::{error::Error, rc::Rc},
}; };
pub(crate) struct NewArgs<P, K> { pub(crate) struct NewArgs<P, K> {
@ -82,7 +82,7 @@ pub(crate) struct Args<P, K> {
} }
fn resolve_stake_authority( fn resolve_stake_authority(
wallet_manager: &mut Option<Arc<RemoteWalletManager>>, wallet_manager: &mut Option<Rc<RemoteWalletManager>>,
key_url: &str, key_url: &str,
) -> Result<Box<dyn Signer>, Box<dyn Error>> { ) -> Result<Box<dyn Signer>, Box<dyn Error>> {
let matches = ArgMatches::default(); let matches = ArgMatches::default();
@ -90,7 +90,7 @@ fn resolve_stake_authority(
} }
fn resolve_withdraw_authority( fn resolve_withdraw_authority(
wallet_manager: &mut Option<Arc<RemoteWalletManager>>, wallet_manager: &mut Option<Rc<RemoteWalletManager>>,
key_url: &str, key_url: &str,
) -> Result<Box<dyn Signer>, Box<dyn Error>> { ) -> Result<Box<dyn Signer>, Box<dyn Error>> {
let matches = ArgMatches::default(); let matches = ArgMatches::default();
@ -98,7 +98,7 @@ fn resolve_withdraw_authority(
} }
fn resolve_new_stake_authority( fn resolve_new_stake_authority(
wallet_manager: &mut Option<Arc<RemoteWalletManager>>, wallet_manager: &mut Option<Rc<RemoteWalletManager>>,
key_url: &str, key_url: &str,
) -> Result<Pubkey, Box<dyn Error>> { ) -> Result<Pubkey, Box<dyn Error>> {
let matches = ArgMatches::default(); let matches = ArgMatches::default();
@ -106,7 +106,7 @@ fn resolve_new_stake_authority(
} }
fn resolve_new_withdraw_authority( fn resolve_new_withdraw_authority(
wallet_manager: &mut Option<Arc<RemoteWalletManager>>, wallet_manager: &mut Option<Rc<RemoteWalletManager>>,
key_url: &str, key_url: &str,
) -> Result<Pubkey, Box<dyn Error>> { ) -> Result<Pubkey, Box<dyn Error>> {
let matches = ArgMatches::default(); let matches = ArgMatches::default();
@ -114,7 +114,7 @@ fn resolve_new_withdraw_authority(
} }
fn resolve_fee_payer( fn resolve_fee_payer(
wallet_manager: &mut Option<Arc<RemoteWalletManager>>, wallet_manager: &mut Option<Rc<RemoteWalletManager>>,
key_url: &str, key_url: &str,
) -> Result<Box<dyn Signer>, Box<dyn Error>> { ) -> Result<Box<dyn Signer>, Box<dyn Error>> {
let matches = ArgMatches::default(); let matches = ArgMatches::default();
@ -122,7 +122,7 @@ fn resolve_fee_payer(
} }
fn resolve_custodian( fn resolve_custodian(
wallet_manager: &mut Option<Arc<RemoteWalletManager>>, wallet_manager: &mut Option<Rc<RemoteWalletManager>>,
key_url: &str, key_url: &str,
) -> Result<Box<dyn Signer>, Box<dyn Error>> { ) -> Result<Box<dyn Signer>, Box<dyn Error>> {
let matches = ArgMatches::default(); let matches = ArgMatches::default();
@ -130,7 +130,7 @@ fn resolve_custodian(
} }
fn resolve_new_custodian( fn resolve_new_custodian(
wallet_manager: &mut Option<Arc<RemoteWalletManager>>, wallet_manager: &mut Option<Rc<RemoteWalletManager>>,
key_url: &Option<String>, key_url: &Option<String>,
) -> Result<Option<Pubkey>, Box<dyn Error>> { ) -> Result<Option<Pubkey>, Box<dyn Error>> {
let matches = ArgMatches::default(); let matches = ArgMatches::default();
@ -145,7 +145,7 @@ fn resolve_new_custodian(
} }
fn resolve_base_pubkey( fn resolve_base_pubkey(
wallet_manager: &mut Option<Arc<RemoteWalletManager>>, wallet_manager: &mut Option<Rc<RemoteWalletManager>>,
key_url: &str, key_url: &str,
) -> Result<Pubkey, Box<dyn Error>> { ) -> Result<Pubkey, Box<dyn Error>> {
let matches = ArgMatches::default(); let matches = ArgMatches::default();
@ -153,7 +153,7 @@ fn resolve_base_pubkey(
} }
fn resolve_new_base_keypair( fn resolve_new_base_keypair(
wallet_manager: &mut Option<Arc<RemoteWalletManager>>, wallet_manager: &mut Option<Rc<RemoteWalletManager>>,
key_url: &str, key_url: &str,
) -> Result<Box<dyn Signer>, Box<dyn Error>> { ) -> Result<Box<dyn Signer>, Box<dyn Error>> {
let matches = ArgMatches::default(); let matches = ArgMatches::default();
@ -161,7 +161,7 @@ fn resolve_new_base_keypair(
} }
fn resolve_authorize_args( fn resolve_authorize_args(
wallet_manager: &mut Option<Arc<RemoteWalletManager>>, wallet_manager: &mut Option<Rc<RemoteWalletManager>>,
args: &AuthorizeArgs<String, String>, args: &AuthorizeArgs<String, String>,
) -> Result<AuthorizeArgs<Pubkey, Box<dyn Signer>>, Box<dyn Error>> { ) -> Result<AuthorizeArgs<Pubkey, Box<dyn Signer>>, Box<dyn Error>> {
let resolved_args = AuthorizeArgs { let resolved_args = AuthorizeArgs {
@ -183,7 +183,7 @@ fn resolve_authorize_args(
} }
fn resolve_set_lockup_args( fn resolve_set_lockup_args(
wallet_manager: &mut Option<Arc<RemoteWalletManager>>, wallet_manager: &mut Option<Rc<RemoteWalletManager>>,
args: &SetLockupArgs<String, String>, args: &SetLockupArgs<String, String>,
) -> Result<SetLockupArgs<Pubkey, Box<dyn Signer>>, Box<dyn Error>> { ) -> Result<SetLockupArgs<Pubkey, Box<dyn Signer>>, Box<dyn Error>> {
let resolved_args = SetLockupArgs { let resolved_args = SetLockupArgs {
@ -201,7 +201,7 @@ fn resolve_set_lockup_args(
} }
fn resolve_rebase_args( fn resolve_rebase_args(
wallet_manager: &mut Option<Arc<RemoteWalletManager>>, wallet_manager: &mut Option<Rc<RemoteWalletManager>>,
args: &RebaseArgs<String, String>, args: &RebaseArgs<String, String>,
) -> Result<RebaseArgs<Pubkey, Box<dyn Signer>>, Box<dyn Error>> { ) -> Result<RebaseArgs<Pubkey, Box<dyn Signer>>, Box<dyn Error>> {
let resolved_args = RebaseArgs { let resolved_args = RebaseArgs {