forked from CympleTech/TDN
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathstop.rs
28 lines (22 loc) · 808 Bytes
/
stop.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
use std::{path::PathBuf, time::Duration};
use tdn::prelude::*;
#[tokio::main]
async fn main() {
let config = Config::load(PathBuf::from("./")).await;
let (_secret, ids, p2p_config, _rpc_config) = config.split();
let (send_send, send_recv) = new_send_channel();
let (recv_send, mut recv_recv) = new_receive_channel();
let peer_id = start_main(ids, p2p_config, recv_send, send_recv, None, None)
.await
.unwrap();
println!("Example: peer id: {:?}", peer_id);
println!("Network will stop after 5s...");
tokio::time::sleep(Duration::from_secs(5)).await;
let _ = send_send
.send(SendMessage::Network(NetworkType::NetworkStop))
.await;
while let Some(_) = recv_recv.recv().await {
//
}
println!("Network is stopped.");
}