-
Notifications
You must be signed in to change notification settings - Fork 17
/
Copy pathv2_get_pool_delegators.rs
42 lines (38 loc) · 1.19 KB
/
v2_get_pool_delegators.rs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
//! Test the `GetPoolDelegators` endpoint.
use anyhow::Context;
use clap::AppSettings;
use concordium_rust_sdk::v2;
use futures::StreamExt;
use structopt::StructOpt;
#[derive(StructOpt)]
struct App {
#[structopt(
long = "node",
help = "GRPC interface of the node.",
default_value = "http://localhost:20000"
)]
endpoint: v2::Endpoint,
}
#[tokio::main(flavor = "multi_thread")]
async fn main() -> anyhow::Result<()> {
let app = {
let app = App::clap().global_setting(AppSettings::ColoredHelp);
let matches = app.get_matches();
App::from_clap(&matches)
};
let mut client = v2::Client::new(app.endpoint)
.await
.context("Cannot connect.")?;
let mut res = client
.get_baker_list(&v2::BlockIdentifier::LastFinal)
.await?;
println!("Blockhash: {}", res.block_hash);
while let Some(a) = res.response.next().await.transpose()? {
let mut response_delegators = client.get_pool_delegators(res.block_hash, a).await?;
println!("Baker {:?}", &a);
while let Some(a) = response_delegators.response.next().await.transpose()? {
println!(" - {:?}", &a);
}
}
Ok(())
}