Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add output query chunk size as temporary env variable (#298) #299

Merged
merged 1 commit into from
Jan 17, 2020
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 23 additions & 1 deletion impls/src/node_clients/http.rs
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ use crate::core::core::TxKernel;
use crate::libwallet::{NodeClient, NodeVersionInfo, TxWrapper};
use semver::Version;
use std::collections::HashMap;
use std::env;
use tokio::runtime::Runtime;

use crate::client_utils::Client;
Expand Down Expand Up @@ -200,7 +201,28 @@ impl NodeClient for HTTPNodeClient {

let client = Client::new();

for query_chunk in query_params.chunks(200) {
// Using an environment variable here, as this is a temporary fix
// and doesn't need to be permeated throughout the application
// configuration
let chunk_default = 200;
let chunk_size = match env::var("GRIN_OUTPUT_QUERY_SIZE") {
Ok(s) => match s.parse::<usize>() {
Ok(c) => c,
Err(e) => {
error!(
"Unable to parse GRIN_OUTPUT_QUERY_SIZE, defaulting to {}",
chunk_default
);
error!("Reason: {}", e);
chunk_default
}
},
Err(_) => chunk_default,
};

trace!("Output query chunk size is: {}", chunk_size);

for query_chunk in query_params.chunks(chunk_size) {
let url = format!("{}/v1/chain/outputs/byids?{}", addr, query_chunk.join("&"),);
tasks.push(client.get_async::<Vec<api::Output>>(url.as_str(), self.node_api_secret()));
}
Expand Down