Skip to content

Commit

Permalink
Merge pull request #25 from fpco/larger-response-size-default
Browse files Browse the repository at this point in the history
Large max decoding size by default
  • Loading branch information
psibi authored Jun 17, 2024
2 parents e950e21 + 6d8532d commit 2e499be
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 28 deletions.
32 changes: 7 additions & 25 deletions packages/cosmos/src/client/node.rs
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ struct NodeInner {
simulate_sequences: RwLock<HashMap<Address, SequenceInformation>>,
broadcast_sequences: RwLock<HashMap<Address, SequenceInformation>>,
query_count: RwLock<QueryCount>,
max_decoding_message_size: Option<usize>,
max_decoding_message_size: usize,
}

#[derive(Default)]
Expand Down Expand Up @@ -272,10 +272,7 @@ impl Node {
let client = cosmos_sdk_proto::cosmos::auth::v1beta1::query_client::QueryClient::new(
self.node_inner.channel.clone(),
);
if let Some(max_decoding_message_size) = self.node_inner.max_decoding_message_size {
return client.max_decoding_message_size(max_decoding_message_size);
}
client
client.max_decoding_message_size(self.node_inner.max_decoding_message_size)
}

pub(crate) fn bank_query_client(
Expand All @@ -284,10 +281,7 @@ impl Node {
let client = cosmos_sdk_proto::cosmos::bank::v1beta1::query_client::QueryClient::new(
self.node_inner.channel.clone(),
);
if let Some(max_decoding_message_size) = self.node_inner.max_decoding_message_size {
return client.max_decoding_message_size(max_decoding_message_size);
}
client
client.max_decoding_message_size(self.node_inner.max_decoding_message_size)
}

pub(crate) fn wasm_query_client(
Expand All @@ -296,10 +290,7 @@ impl Node {
let client = cosmos_sdk_proto::cosmwasm::wasm::v1::query_client::QueryClient::new(
self.node_inner.channel.clone(),
);
if let Some(max_decoding_message_size) = self.node_inner.max_decoding_message_size {
return client.max_decoding_message_size(max_decoding_message_size);
}
client
client.max_decoding_message_size(self.node_inner.max_decoding_message_size)
}

pub(crate) fn tx_service_client(
Expand All @@ -308,10 +299,7 @@ impl Node {
let client = cosmos_sdk_proto::cosmos::tx::v1beta1::service_client::ServiceClient::new(
self.node_inner.channel.clone(),
);
if let Some(max_decoding_message_size) = self.node_inner.max_decoding_message_size {
return client.max_decoding_message_size(max_decoding_message_size);
}
client
client.max_decoding_message_size(self.node_inner.max_decoding_message_size)
}

pub(crate) fn tendermint_client(
Expand All @@ -323,10 +311,7 @@ impl Node {
cosmos_sdk_proto::cosmos::base::tendermint::v1beta1::service_client::ServiceClient::new(
self.node_inner.channel.clone(),
);
if let Some(max_decoding_message_size) = self.node_inner.max_decoding_message_size {
return client.max_decoding_message_size(max_decoding_message_size);
}
client
client.max_decoding_message_size(self.node_inner.max_decoding_message_size)
}

pub(crate) fn authz_query_client(
Expand All @@ -335,10 +320,7 @@ impl Node {
let client = cosmos_sdk_proto::cosmos::authz::v1beta1::query_client::QueryClient::new(
self.node_inner.channel.clone(),
);
if let Some(max_decoding_message_size) = self.node_inner.max_decoding_message_size {
return client.max_decoding_message_size(max_decoding_message_size);
}
client
client.max_decoding_message_size(self.node_inner.max_decoding_message_size)
}

pub(crate) fn epochs_query_client(
Expand Down
6 changes: 3 additions & 3 deletions packages/cosmos/src/cosmos_builder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -454,9 +454,9 @@ impl CosmosBuilder {

/// Limits the maximum size of a decoded message.
///
/// Default: 4 MB
pub fn get_max_decoding_message_size(&self) -> Option<usize> {
self.max_decoding_message_size
/// Default: 16 MB
pub fn get_max_decoding_message_size(&self) -> usize {
self.max_decoding_message_size.unwrap_or(16 * 1024 * 1024)
}

/// See [Self::get_max_decoding_message_size]
Expand Down

0 comments on commit 2e499be

Please sign in to comment.