How to Embed a Node in Your Application
Last updated
use ant_node::{NodeBuilder, NodeConfig};
#[tokio::main]
async fn main() -> Result<(), Box<dyn std::error::Error>> {
let mut config = NodeConfig::development();
config.root_dir = "./embedded-node".into();
let mut node = NodeBuilder::new(config).build().await?;
node.run().await?;
Ok(())
}let mut node = NodeBuilder::new(NodeConfig::development()).build().await?;
let mut events = node.subscribe_events();
tokio::spawn(async move {
while let Ok(event) = events.recv().await {
println!("{event:?}");
}
});