forked from Cardinal-Cryptography/aleph-node
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsynthetic_network.rs
More file actions
29 lines (24 loc) · 902 Bytes
/
synthetic_network.rs
File metadata and controls
29 lines (24 loc) · 902 Bytes
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
use log::info;
use synthetic_link::SyntheticNetworkClient;
pub type Milliseconds = u64;
fn create_client(node_name: &str) -> SyntheticNetworkClient {
let synthetic_network_url = format!("http://{}:80/qos", node_name);
info!("creating an http client for url {}", synthetic_network_url);
SyntheticNetworkClient::new(synthetic_network_url)
}
pub async fn set_out_latency(milliseconds: Milliseconds, node_name: &str) {
info!(
"setting out-latency of node {} to {}ms",
node_name, milliseconds
);
let mut client = create_client(node_name);
let mut config = client
.load_config()
.await
.expect("we should be able to download config of the synthetic-network ");
config.default_link.egress.latency = milliseconds;
client
.commit_config(&config)
.await
.expect("unable to commit network configuration");
}