Skip to content

Commit

Permalink
Put clone() to where it is needed
Browse files Browse the repository at this point in the history
  • Loading branch information
whs-dot-hk committed Oct 2, 2024
1 parent 84743a2 commit 00823ec
Show file tree
Hide file tree
Showing 10 changed files with 27 additions and 27 deletions.
2 changes: 1 addition & 1 deletion crates/chain-registry/src/querier.rs
Original file line number Diff line number Diff line change
Expand Up @@ -160,7 +160,7 @@ impl QueryContext for GrpcHealthCheckQuerier {

info!("Querying gRPC server at {tendermint_url}");

create_grpc_client(uri, QueryClient::new)
create_grpc_client(&uri, QueryClient::new)
.await
.map_err(|_| RegistryError::unable_to_connect_with_grpc())?;

Expand Down
26 changes: 13 additions & 13 deletions crates/relayer/src/chain/cosmos.rs
Original file line number Diff line number Diff line change
Expand Up @@ -377,7 +377,7 @@ impl CosmosSdkChain {
crate::telemetry!(query, self.id(), "query_ccv_consumer_chain_params");

let mut client = self.block_on(create_grpc_client(
self.grpc_addr.clone(),
&self.grpc_addr,
ibc_proto::interchain_security::ccv::consumer::v1::query_client::QueryClient::new,
))?;

Expand Down Expand Up @@ -1228,7 +1228,7 @@ impl ChainEndpoint for CosmosSdkChain {
crate::telemetry!(query, self.id(), "query_clients");

let mut client = self.block_on(create_grpc_client(
self.grpc_addr.clone(),
&self.grpc_addr,
ibc_proto::ibc::core::client::v1::query_client::QueryClient::new,
))?;

Expand Down Expand Up @@ -1416,7 +1416,7 @@ impl ChainEndpoint for CosmosSdkChain {
crate::telemetry!(query, self.id(), "query_client_connections");

let mut client = self.block_on(create_grpc_client(
self.grpc_addr.clone(),
&self.grpc_addr,
ibc_proto::ibc::core::connection::v1::query_client::QueryClient::new,
))?;

Expand Down Expand Up @@ -1459,7 +1459,7 @@ impl ChainEndpoint for CosmosSdkChain {
crate::telemetry!(query, self.id(), "query_connections");

let mut client = self.block_on(create_grpc_client(
self.grpc_addr.clone(),
&self.grpc_addr,
ibc_proto::ibc::core::connection::v1::query_client::QueryClient::new,
))?;

Expand Down Expand Up @@ -1514,7 +1514,7 @@ impl ChainEndpoint for CosmosSdkChain {
use tonic::IntoRequest;

let mut client = create_grpc_client(
chain.grpc_addr.clone(),
&chain.grpc_addr,
connection::query_client::QueryClient::new,
)
.await?;
Expand Down Expand Up @@ -1596,7 +1596,7 @@ impl ChainEndpoint for CosmosSdkChain {
crate::telemetry!(query, self.id(), "query_connection_channels");

let mut client = self.block_on(create_grpc_client(
self.grpc_addr.clone(),
&self.grpc_addr,
ibc_proto::ibc::core::channel::v1::query_client::QueryClient::new,
))?;

Expand Down Expand Up @@ -1665,7 +1665,7 @@ impl ChainEndpoint for CosmosSdkChain {
crate::telemetry!(query, self.id(), "query_channels");

let mut client = self.block_on(create_grpc_client(
self.grpc_addr.clone(),
&self.grpc_addr,
ibc_proto::ibc::core::channel::v1::query_client::QueryClient::new,
))?;

Expand Down Expand Up @@ -1786,7 +1786,7 @@ impl ChainEndpoint for CosmosSdkChain {
crate::telemetry!(query, self.id(), "query_channel_client_state");

let mut client = self.block_on(create_grpc_client(
self.grpc_addr.clone(),
&self.grpc_addr,
ibc_proto::ibc::core::channel::v1::query_client::QueryClient::new,
))?;

Expand Down Expand Up @@ -1854,7 +1854,7 @@ impl ChainEndpoint for CosmosSdkChain {

let mut client = self
.block_on(create_grpc_client(
self.grpc_addr.clone(),
&self.grpc_addr,
ibc_proto::ibc::core::channel::v1::query_client::QueryClient::new,
))
.map(|client| {
Expand Down Expand Up @@ -2025,7 +2025,7 @@ impl ChainEndpoint for CosmosSdkChain {
crate::telemetry!(query, self.id(), "query_unreceived_packets");

let mut client = self.block_on(create_grpc_client(
self.grpc_addr.clone(),
&self.grpc_addr,
ibc_proto::ibc::core::channel::v1::query_client::QueryClient::new,
))?;

Expand Down Expand Up @@ -2098,7 +2098,7 @@ impl ChainEndpoint for CosmosSdkChain {

let mut client = self
.block_on(create_grpc_client(
self.grpc_addr.clone(),
&self.grpc_addr,
ibc_proto::ibc::core::channel::v1::query_client::QueryClient::new,
))
.map(|client| {
Expand Down Expand Up @@ -2216,7 +2216,7 @@ impl ChainEndpoint for CosmosSdkChain {
crate::telemetry!(query, self.id(), "query_unreceived_acknowledgements");

let mut client = self.block_on(create_grpc_client(
self.grpc_addr.clone(),
&self.grpc_addr,
ibc_proto::ibc::core::channel::v1::query_client::QueryClient::new,
))?;

Expand Down Expand Up @@ -2554,7 +2554,7 @@ impl ChainEndpoint for CosmosSdkChain {
crate::telemetry!(query, self.id(), "query_consumer_chains");

let mut client = self.block_on(create_grpc_client(
self.grpc_addr.clone(),
&self.grpc_addr,
ibc_proto::interchain_security::ccv::provider::v1::query_client::QueryClient::new,
))?;

Expand Down
2 changes: 1 addition & 1 deletion crates/relayer/src/chain/cosmos/query/account.rs
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ pub async fn query_account(
grpc_address: &Uri,
account_address: &str,
) -> Result<BaseAccount, Error> {
let mut client = create_grpc_client(grpc_address.clone(), QueryClient::new).await?;
let mut client = create_grpc_client(grpc_address, QueryClient::new).await?;

client = client.max_decoding_message_size(max_grpc_decoding_size().get_bytes() as usize);

Expand Down
4 changes: 2 additions & 2 deletions crates/relayer/src/chain/cosmos/query/balance.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ pub async fn query_balance(
account_address: &str,
denom: &str,
) -> Result<Balance, Error> {
let mut client = create_grpc_client(grpc_address.clone(), QueryClient::new).await?;
let mut client = create_grpc_client(grpc_address, QueryClient::new).await?;

client = client.max_decoding_message_size(max_grpc_decoding_size().get_bytes() as usize);

Expand Down Expand Up @@ -46,7 +46,7 @@ pub async fn query_all_balances(
grpc_address: &Uri,
account_address: &str,
) -> Result<Vec<Balance>, Error> {
let mut client = create_grpc_client(grpc_address.clone(), QueryClient::new).await?;
let mut client = create_grpc_client(grpc_address, QueryClient::new).await?;

client = client.max_decoding_message_size(max_grpc_decoding_size().get_bytes() as usize);

Expand Down
2 changes: 1 addition & 1 deletion crates/relayer/src/chain/cosmos/query/connection.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ use crate::util::create_grpc_client;

/// Uses the GRPC client to retrieve the connection params
pub async fn query_connection_params(grpc_address: &Uri) -> Result<Params, Error> {
let mut client = create_grpc_client(grpc_address.clone(), QueryClient::new).await?;
let mut client = create_grpc_client(grpc_address, QueryClient::new).await?;

client = client.max_decoding_message_size(max_grpc_decoding_size().get_bytes() as usize);

Expand Down
4 changes: 2 additions & 2 deletions crates/relayer/src/chain/cosmos/query/consensus_state.rs
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ pub async fn query_consensus_state_heights(
}

let mut client = create_grpc_client(
grpc_addr.clone(),
grpc_addr,
ibc_proto::ibc::core::client::v1::query_client::QueryClient::new,
)
.await?;
Expand Down Expand Up @@ -108,7 +108,7 @@ pub async fn query_consensus_states(
);

let mut client = create_grpc_client(
grpc_addr.clone(),
grpc_addr,
ibc_proto::ibc::core::client::v1::query_client::QueryClient::new,
)
.await?;
Expand Down
2 changes: 1 addition & 1 deletion crates/relayer/src/chain/cosmos/query/denom_trace.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ use crate::util::create_grpc_client;

// Uses the GRPC client to retrieve the denom trace for a specific hash
pub async fn query_denom_trace(grpc_address: &Uri, hash: &str) -> Result<DenomTrace, Error> {
let mut client = create_grpc_client(grpc_address.clone(), QueryClient::new).await?;
let mut client = create_grpc_client(grpc_address, QueryClient::new).await?;

client = client.max_decoding_message_size(max_grpc_decoding_size().get_bytes() as usize);

Expand Down
6 changes: 3 additions & 3 deletions crates/relayer/src/chain/cosmos/query/fee.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ pub async fn query_counterparty_payee(
channel_id: &ChannelId,
address: &Signer,
) -> Result<Option<String>, Error> {
let mut client = create_grpc_client(grpc_address.clone(), QueryClient::new).await?;
let mut client = create_grpc_client(grpc_address, QueryClient::new).await?;

client = client.max_decoding_message_size(max_grpc_decoding_size().get_bytes() as usize);

Expand Down Expand Up @@ -52,7 +52,7 @@ pub async fn query_incentivized_packets(
channel_id: &ChannelId,
port_id: &PortId,
) -> Result<Vec<IdentifiedPacketFees>, Error> {
let mut client = create_grpc_client(grpc_address.clone(), QueryClient::new).await?;
let mut client = create_grpc_client(grpc_address, QueryClient::new).await?;

client = client.max_decoding_message_size(max_grpc_decoding_size().get_bytes() as usize);

Expand Down Expand Up @@ -84,7 +84,7 @@ pub async fn query_incentivized_packet(
grpc_address: &Uri,
request: QueryIncentivizedPacketRequest,
) -> Result<QueryIncentivizedPacketResponse, Error> {
let mut client = create_grpc_client(grpc_address.clone(), QueryClient::new).await?;
let mut client = create_grpc_client(grpc_address, QueryClient::new).await?;

client = client.max_decoding_message_size(max_grpc_decoding_size().get_bytes() as usize);

Expand Down
2 changes: 1 addition & 1 deletion crates/relayer/src/chain/cosmos/simulate.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ pub async fn send_tx_simulate(grpc_address: &Uri, tx: Tx) -> Result<SimulateResp
..Default::default()
};

let mut client = create_grpc_client(grpc_address.clone(), ServiceClient::new).await?;
let mut client = create_grpc_client(grpc_address, ServiceClient::new).await?;

client = client.max_decoding_message_size(max_grpc_decoding_size().get_bytes() as usize);

Expand Down
4 changes: 2 additions & 2 deletions crates/relayer/src/util.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,11 @@ pub mod task;

/// Helper function to create a gRPC client.
pub async fn create_grpc_client<T>(
grpc_addr: tonic::transport::Uri,
grpc_addr: &tonic::transport::Uri,
client_constructor: impl FnOnce(tonic::transport::Channel) -> T,
) -> Result<T, crate::error::Error> {
let tls_config = tonic::transport::ClientTlsConfig::new().with_native_roots();
let channel = tonic::transport::Channel::builder(grpc_addr)
let channel = tonic::transport::Channel::builder(grpc_addr.clone())
.tls_config(tls_config)
.map_err(crate::error::Error::grpc_transport)?
.connect()
Expand Down

0 comments on commit 00823ec

Please sign in to comment.