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

Limit node queries to 120 outputs at once #165

Merged
merged 1 commit into from
Jun 26, 2019
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
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