Skip to content
This repository has been archived by the owner on Aug 9, 2024. It is now read-only.

Commit

Permalink
fix(operator): fetch env (#172)
Browse files Browse the repository at this point in the history
  • Loading branch information
ratankaliani authored May 3, 2024
1 parent d703783 commit d653cd5
Showing 1 changed file with 23 additions and 12 deletions.
35 changes: 23 additions & 12 deletions bin/vectorx.rs
Original file line number Diff line number Diff line change
Expand Up @@ -374,8 +374,11 @@ impl VectorXOperator {
Some(min(max_block_to_request, last_justified_block))
}

async fn run(&mut self, loop_delay_mins: u64, block_interval: u32) {
async fn run(&mut self) {
loop {
let loop_delay_mins = get_loop_delay_mins();
let block_interval = get_update_delay_blocks();

// Check if there is a rotate available for the next authority set.
self.find_and_request_rotate().await;

Expand Down Expand Up @@ -411,30 +414,38 @@ impl VectorXOperator {
}
}

#[tokio::main]
async fn main() {
env::set_var("RUST_LOG", "info");
dotenv::dotenv().ok();
env_logger::init();

let data_fetcher = RpcDataFetcher::new().await;

fn get_loop_delay_mins() -> u64 {
let loop_delay_mins_env = env::var("LOOP_DELAY_MINS");
let mut loop_delay_mins = 5;
let mut loop_delay_mins = 15;
if loop_delay_mins_env.is_ok() {
loop_delay_mins = loop_delay_mins_env
.unwrap()
.parse::<u64>()
.expect("invalid LOOP_DELAY_MINS");
}
loop_delay_mins
}

fn get_update_delay_blocks() -> u32 {
let update_delay_blocks_env = env::var("UPDATE_DELAY_BLOCKS");
let mut update_delay_blocks = 200;
let mut update_delay_blocks = 180;
if update_delay_blocks_env.is_ok() {
update_delay_blocks = update_delay_blocks_env
.unwrap()
.parse::<u32>()
.expect("invalid UPDATE_DELAY_BLOCKS");
}
update_delay_blocks
}

#[tokio::main]
async fn main() {
env::set_var("RUST_LOG", "info");
dotenv::dotenv().ok();
env_logger::init();

let data_fetcher = RpcDataFetcher::new().await;

let mut operator = VectorXOperator::new(data_fetcher).await;
operator.run(loop_delay_mins, update_delay_blocks).await;
operator.run().await;
}

0 comments on commit d653cd5

Please sign in to comment.