Skip to content

Commit 0728344

Browse files
committed
Reduce use of send RpcClient
1 parent 855d29f commit 0728344

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

src/lib.rs

+6-2
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,9 @@ pub fn app_version() -> String {
2424

2525
pub struct RpcClients {
2626
pub default: RpcClient,
27+
28+
// Optional `RpcClient` for use only for sending transactions.
29+
// If `None` then the `default` client is used for sending transactions
2730
pub send: Option<RpcClient>,
2831
}
2932

@@ -41,7 +44,8 @@ pub fn send_transaction_until_expired(
4144
},
4245
};
4346

44-
let rpc_client = rpc_clients.send.as_ref().unwrap_or(&rpc_clients.default);
47+
let send_rpc_client = rpc_clients.send.as_ref().unwrap_or(&rpc_clients.default);
48+
let rpc_client = &rpc_clients.default;
4549

4650
let mut last_send_attempt = None;
4751

@@ -76,7 +80,7 @@ pub fn send_transaction_until_expired(
7680
"Sending transaction {} [{valid_msg}]",
7781
transaction.get_signature()
7882
);
79-
if let Err(err) = rpc_client.send_transaction_with_config(transaction, config) {
83+
if let Err(err) = send_rpc_client.send_transaction_with_config(transaction, config) {
8084
println!("Transaction failed to send: {err:?}");
8185
}
8286
last_send_attempt = Some(Instant::now());

0 commit comments

Comments
 (0)