Files
heartwood/crates/radicle-cli/src/commands/node/events.rs
T
Lorenz Leutgeb 5bc2dc677b repo: Move workspace crates into crates subdirectory
This keeps the top level of the repo cleaner, e.g.
<https://github.com/radicle-dev/heartwood> scrolls less and
<https://app.radicle.xyz/nodes/rosa.radicle.xyz/rad:z3gqcJUoA1n9HaHKufZs5FCSGazv5/>
might show more files at the top level.

This way we also don't have to explicitly name all crates in
`Cargo.toml`.
2025-06-09 15:09:21 +02:00

24 lines
532 B
Rust

use std::time;
use radicle::node::{Event, Handle};
pub fn run<H>(node: H, count: usize, timeout: time::Duration) -> anyhow::Result<()>
where
H: Handle<Event = Result<Event, <H as Handle>::Error>>,
{
let events = node.subscribe(timeout)?;
for (i, event) in events.into_iter().enumerate() {
let event = event?;
let obj = serde_json::to_string(&event)?;
println!("{obj}");
// Only output up to `count` events.
if i + 1 >= count {
break;
}
}
Ok(())
}