Skip to content
This repository has been archived by the owner on Apr 3, 2023. It is now read-only.

Commit

Permalink
Merge pull request #165 from NotMrPotter/fix/output_update_URI_length
Browse files Browse the repository at this point in the history
Limit node queries to 120 outputs at once
  • Loading branch information
jaspervdm authored Jun 26, 2019
2 parents cf83e3a + 8fcb48e commit c3bd6a3
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions src/wallet/types/node_client.rs
Original file line number Diff line number Diff line change
Expand Up @@ -143,18 +143,18 @@ impl NodeClient for HTTPNodeClient {
) -> Result<HashMap<Commitment, (String, u64, u64)>, Error> {
let addr = self.node_url();
// build the necessary query params -
// ?id=xxx&id=yyy&id=zzz
// ?id=xxx,yyy,zzz
let query_params: Vec<String> = wallet_outputs
.iter()
.map(|commit| format!("id={}", to_hex(commit.as_ref().to_vec())))
.map(|commit| format!("{}", to_hex(commit.as_ref().to_vec())))
.collect();

// build a map of api outputs by commit so we can look them up efficiently
let mut api_outputs: HashMap<Commitment, (String, u64, u64)> = HashMap::new();
let mut tasks = Vec::new();

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

0 comments on commit c3bd6a3

Please sign in to comment.