use rust_ipfs::{Ipfs, IpfsOptions, TestTypes, UninitializedIpfs, PublicKey, p2p::PeerInfo};
#[tokio::main]
async fn main() -> anyhow::Result<()> {
tracing_subscriber::fmt::init();
let opts = IpfsOptions::default();
let ipfs: Ipfs<TestTypes> = UninitializedIpfs::new(opts).spawn_start().await?;
tokio::time::sleep(std::time::Duration::from_secs(1)).await;
let PeerInfo { public_key: key, listen_addrs: addresses, ..} = ipfs.identity(None).await?;
if let PublicKey::Ed25519(publickey) = &key {
println!("Public Key: {}", bs58::encode(publickey.encode()).into_string());
}
println!("PeerID: {}", key.to_peer_id());
for address in addresses {
println!("Listening on: {}", address);
}
ipfs.exit_daemon().await;
Ok(())
}