mod cli;
pub mod config;
use std::{
panic::{self, PanicInfo},
process,
};
use backtrace::Backtrace;
use structopt::StructOpt;
use tokio::runtime::Builder;
use casper_node::MAX_THREAD_COUNT;
use cli::Cli;
fn panic_hook(info: &PanicInfo) {
let backtrace = Backtrace::new();
eprintln!("{:?}", backtrace);
if let Some(s) = info.payload().downcast_ref::<&str>() {
eprintln!("node panicked: {}", s);
} else {
eprintln!("{}", info);
}
process::abort()
}
fn main() -> anyhow::Result<()> {
let mut runtime = Builder::new()
.threaded_scheduler()
.enable_all()
.max_threads(MAX_THREAD_COUNT)
.build()
.unwrap();
panic::set_hook(Box::new(panic_hook));
let opts = Cli::from_args();
runtime.block_on(async { opts.run().await })
}