Skip to content

Commit

Permalink
remove unnecessary mutex (#3919)
Browse files Browse the repository at this point in the history
  • Loading branch information
KirillLykov authored Dec 4, 2024
1 parent 1ebeb30 commit 0276c07
Showing 1 changed file with 14 additions and 10 deletions.
24 changes: 14 additions & 10 deletions rpc/src/rpc.rs
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ use {
str::FromStr,
sync::{
atomic::{AtomicBool, AtomicU64, Ordering},
Arc, Mutex, RwLock,
Arc, RwLock,
},
time::Duration,
},
Expand Down Expand Up @@ -214,7 +214,7 @@ pub struct JsonRpcRequestProcessor {
health: Arc<RpcHealth>,
cluster_info: Arc<ClusterInfo>,
genesis_hash: Hash,
transaction_sender: Arc<Mutex<Sender<TransactionInfo>>>,
transaction_sender: Sender<TransactionInfo>,
bigtable_ledger_storage: Option<solana_storage_bigtable::LedgerStorage>,
optimistically_confirmed_bank: Arc<RwLock<OptimisticallyConfirmedBank>>,
largest_accounts_cache: Arc<RwLock<LargestAccountsCache>>,
Expand Down Expand Up @@ -330,7 +330,7 @@ impl JsonRpcRequestProcessor {
max_complete_rewards_slot: Arc<AtomicU64>,
prioritization_fee_cache: Arc<PrioritizationFeeCache>,
) -> (Self, Receiver<TransactionInfo>) {
let (sender, receiver) = unbounded();
let (transaction_sender, transaction_receiver) = unbounded();
(
Self {
config,
Expand All @@ -342,7 +342,7 @@ impl JsonRpcRequestProcessor {
health,
cluster_info,
genesis_hash,
transaction_sender: Arc::new(Mutex::new(sender)),
transaction_sender,
bigtable_ledger_storage,
optimistically_confirmed_bank,
largest_accounts_cache,
Expand All @@ -352,7 +352,7 @@ impl JsonRpcRequestProcessor {
max_complete_rewards_slot,
prioritization_fee_cache,
},
receiver,
transaction_receiver,
)
}

Expand All @@ -379,7 +379,7 @@ impl JsonRpcRequestProcessor {
.my_contact_info()
.tpu(connection_cache.protocol())
.unwrap();
let (sender, receiver) = unbounded();
let (transaction_sender, transaction_receiver) = unbounded();

let client = ConnectionCacheClient::<NullTpuInfo>::new(
connection_cache.clone(),
Expand All @@ -388,7 +388,13 @@ impl JsonRpcRequestProcessor {
None,
1,
);
SendTransactionService::new(&bank_forks, receiver, client, 1000, exit.clone());
SendTransactionService::new(
&bank_forks,
transaction_receiver,
client,
1000,
exit.clone(),
);

let leader_schedule_cache = Arc::new(LeaderScheduleCache::new_from_bank(&bank));
let startup_verification_complete = Arc::clone(bank.get_startup_verification_complete());
Expand All @@ -415,7 +421,7 @@ impl JsonRpcRequestProcessor {
)),
cluster_info,
genesis_hash,
transaction_sender: Arc::new(Mutex::new(sender)),
transaction_sender,
bigtable_ledger_storage: None,
optimistically_confirmed_bank,
largest_accounts_cache: Arc::new(RwLock::new(LargestAccountsCache::new(30))),
Expand Down Expand Up @@ -2541,8 +2547,6 @@ fn _send_transaction(
None,
);
meta.transaction_sender
.lock()
.unwrap()
.send(transaction_info)
.unwrap_or_else(|err| warn!("Failed to enqueue transaction: {}", err));

Expand Down

0 comments on commit 0276c07

Please sign in to comment.