aboutsummaryrefslogtreecommitdiff
path: root/p2p/examples
diff options
context:
space:
mode:
Diffstat (limited to 'p2p/examples')
-rw-r--r--p2p/examples/monitor.rs25
1 files changed, 22 insertions, 3 deletions
diff --git a/p2p/examples/monitor.rs b/p2p/examples/monitor.rs
index 5da55aa..7b9e5d2 100644
--- a/p2p/examples/monitor.rs
+++ b/p2p/examples/monitor.rs
@@ -61,12 +61,29 @@ fn main() {
let exc = ex.clone();
run_executor(
async {
- let monitor = backend.monitor().await;
+ let monitor = backend.monitor();
+ let conn_listener = monitor.conn_events().await;
+ let peerpool_listener = monitor.peer_pool_events().await;
+ let discovery_listener = monitor.discovery_events().await;
let monitor_task = exc.spawn(async move {
loop {
- let event = monitor.recv().await.unwrap();
- println!("{}", event);
+ let event = conn_listener.recv().await.unwrap();
+ println!("New connection event: {}", event);
+ }
+ });
+
+ let monitor_task2 = exc.spawn(async move {
+ loop {
+ let event = peerpool_listener.recv().await.unwrap();
+ println!("New peer pool event: {}", event);
+ }
+ });
+
+ let monitor_task3 = exc.spawn(async move {
+ loop {
+ let event = discovery_listener.recv().await.unwrap();
+ println!("New discovery event: {}", event);
}
});
@@ -80,6 +97,8 @@ fn main() {
backend.shutdown().await;
monitor_task.cancel().await;
+ monitor_task2.cancel().await;
+ monitor_task3.cancel().await;
},
ex,
);