Skip to content

Commit

Permalink
Merge pull request #36 from waves-exchange/rates_by_100
Browse files Browse the repository at this point in the history
requests rates service by 100 items
  • Loading branch information
wild-man authored Oct 26, 2022
2 parents d334428 + 64a3d17 commit 4e358ea
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 5 deletions.
2 changes: 1 addition & 1 deletion wavesexchange_apis/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "wavesexchange_apis"
version = "0.1.7"
version = "0.1.8"
edition = "2021"
authors = ["Artem Sidorenko <[email protected]>"]

Expand Down
18 changes: 14 additions & 4 deletions wavesexchange_apis/src/api_clients/rates.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,21 @@ impl HttpClient<RatesService> {
.map(|(a, b)| format!("{}/{}", a.into(), b.into()))
.collect::<Vec<_>>();

let body = dto::RatesRequest { pairs };
let mut rates = vec![];

self.create_req_handler(self.http_post("rates").json(&body), "rates::rates")
.execute()
.await
for chunk_pairs in pairs.chunks(100) {
let body = dto::RatesRequest {
pairs: chunk_pairs.to_vec(),
};
let mut resp: dto::RatesResponse = self
.create_req_handler(self.http_post("rates").json(&body), "rates::rates")
.execute()
.await?;

rates.append(&mut resp.data);
}

Ok(dto::RatesResponse { data: rates })
}
}

Expand Down

0 comments on commit 4e358ea

Please sign in to comment.