aboutsummaryrefslogtreecommitdiff
path: root/src/util.rs
diff options
context:
space:
mode:
Diffstat (limited to 'src/util.rs')
-rw-r--r--src/util.rs4
1 files changed, 4 insertions, 0 deletions
diff --git a/src/util.rs b/src/util.rs
index a87f779..bf8f4cb 100644
--- a/src/util.rs
+++ b/src/util.rs
@@ -4,6 +4,7 @@ use log::info;
use tokio::sync::watch;
+/// A node's identifier, which is also its public cryptographic key
pub type NodeID = sodiumoxide::crypto::sign::ed25519::PublicKey;
/// Utility function: encodes any serializable value in MessagePack binary format
@@ -25,6 +26,7 @@ where
/// This async function returns only when a true signal was received
/// from a watcher that tells us when to exit.
+///
/// Usefull in a select statement to interrupt another
/// future:
/// ```ignore
@@ -41,6 +43,8 @@ pub async fn await_exit(mut must_exit: watch::Receiver<bool>) {
}
}
+/// Creates a watch that contains `false`, and that changes
+/// to `true` when a Ctrl+C signal is received.
pub fn watch_ctrl_c() -> watch::Receiver<bool> {
let (send_cancel, watch_cancel) = watch::channel(false);
tokio::spawn(async move {