1use std::{path::PathBuf, time::Duration};
2use tdn::prelude::*;
3
4#[tokio::main]
5async fn main() {
6 let config = Config::load(PathBuf::from("./")).await;
7 let (_secret, ids, p2p_config, _rpc_config) = config.split();
8 let (send_send, send_recv) = new_send_channel();
9 let (recv_send, mut recv_recv) = new_receive_channel();
10
11 let peer_id = start_main(ids, p2p_config, recv_send, send_recv, None, None)
12 .await
13 .unwrap();
14 println!("Example: peer id: {:?}", peer_id);
15
16 println!("Network will stop after 5s...");
17 tokio::time::sleep(Duration::from_secs(5)).await;
18
19 let _ = send_send
20 .send(SendMessage::Network(NetworkType::NetworkStop))
21 .await;
22
23 while let Some(_) = recv_recv.recv().await {
24 }
26
27 println!("Network is stopped.");
28}