You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
This may be a noob question.
When using sdks in other languages, I would typically instantiate a single client and use it to fetch all the data. This solves the problem entirely.
In this library, however, the methods are assigned to different structs. I tried to use instantiate a Client struct but that's in a private module.
The following code would log "Connection reset by peer" errors
#[tokio::main]
async fn main() {
let list = get_list().await;
fetch_books(&list).await;
let _ = time::sleep(time::Duration::from_secs(60)).await;
}
async fn get_list() -> Vec<String> {
let client: General = Binance::new(None, None);
match client.exchange_info().await {
Err(_) => panic!("List Fetch Failed, Aborting \n"),
Ok(x) => x
.symbols
.into_iter()
.filter(|y| y.quote_asset == "USDT" && y.status == "TRADING")
.map(|z| z.symbol)
.collect(),
}
}
#[allow(dead_code)]
async fn fetch_books(list: &Vec<String>) {
let client = Arc::new(Market::new(None, None));
list.into_iter().for_each(|x| {
let client_copy = Arc::clone(&client);
let symbol = x.clone();
task::spawn(async move {
if let Err(e) = client_copy.get_depth(symbol).await {
panic!("{e:?}");
}
});
})
}
The text was updated successfully, but these errors were encountered:
This may be a noob question.
When using sdks in other languages, I would typically instantiate a single client and use it to fetch all the data. This solves the problem entirely.
In this library, however, the methods are assigned to different structs. I tried to use instantiate a Client struct but that's in a private module.
The following code would log "Connection reset by peer" errors
The text was updated successfully, but these errors were encountered: