-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.rs
47 lines (43 loc) · 1.35 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
use eyre::Result;
use operator::Operator;
use std::env;
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<()> {
init_tracing();
let args: Vec<String> = env::args().collect();
match args.len() {
3 => {
// Correct number of arguments, continue with the private key
let private_key = args[1].clone();
let chain = args[2].clone().into();
let operator = Operator::new(&private_key, chain).await?;
operator.run().await
}
_ => {
error!("Usage: {} <private_key> <chain>", args[0]);
error!("Both the private key and chain are expected as arguments");
std::process::exit(1);
}
}
}