use p2cm::{Comms, DiscoveryConfig};
use tracing_subscriber::{fmt, prelude::*, EnvFilter};

#[tokio::main]
async fn main() -> anyhow::Result<()> {
    tracing_subscriber::registry()
        .with(fmt::layer())
        .with(EnvFilter::from_default_env().add_directive("p2cm=debug".parse()?))
        .init();

    tracing::info!("Starting p2cm P2P example");

    let mut comms = Comms::new().await?;

    tracing::info!("Local peer ID: {}", comms.local_peer_id());

    comms.start_discovery().await?;

    tokio::signal::ctrl_c().await?;

    tracing::info!("Shutting down...");
    Ok(())
}