Skip to content

Commit

Permalink
add output query chunk size as temporary env variable (mimblewimble#298
Browse files Browse the repository at this point in the history
  • Loading branch information
yeastplume authored Jan 17, 2020
1 parent e2483e1 commit 37d8811
Showing 1 changed file with 23 additions and 1 deletion.
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

0 comments on commit 37d8811

Please sign in to comment.