-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.rs
54 lines (47 loc) · 1.41 KB
/
main.rs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
use std::env;
use aggregator::Aggregator;
use eyre::Result;
use time::macros::format_description;
use tracing::error;
use tracing_subscriber::fmt;
fn init_tracing() {
// Initialize the tracing subscriber with custom filter and format
let format = fmt::format()
.with_level(true)
.with_target(true)
.with_thread_ids(false)
.with_thread_names(false)
.with_timer(fmt::time::UtcTime::new(format_description!(
"[year]-[month]-[day] [hour]:[minute]:[second]"
)))
.compact()
.with_source_location(false)
.with_ansi(true);
tracing_subscriber::fmt()
.event_format(format)
.with_max_level(tracing::Level::INFO)
.init();
}
#[tokio::main]
async fn main() -> Result<()> {
// Initialize tracing
init_tracing();
let args: Vec<String> = env::args().collect();
match args.len() {
2 => {
// Correct number of arguments, continue with the private key
let chain = args[1].clone().into();
let mut aggregator = Aggregator::new(chain).await?;
aggregator.run().await?
}
_ => {
error!("Usage: {} <chain> ", args[0]);
error!("Only the chain is expected as argument");
std::process::exit(1);
}
}
// Keep the main thread running
tokio::signal::ctrl_c().await?;
println!("Shutting down");
Ok(())
}