liquidator: fix token info for same-name, fix delays (#795)

This commit is contained in:
Christian Kamm 2023-11-24 11:04:59 +01:00 committed by GitHub
parent 9a68a2dd7d
commit 0483faef1e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 5 additions and 4 deletions

View File

@ -519,11 +519,11 @@ async fn main() -> anyhow::Result<()> {
let token_swap_info_job = tokio::spawn({ let token_swap_info_job = tokio::spawn({
// TODO: configurable interval // TODO: configurable interval
let mut interval = tokio::time::interval(Duration::from_secs(60)); let mut interval = tokio::time::interval(Duration::from_secs(60));
let mut min_delay = tokio::time::interval(Duration::from_secs(1)); let mut startup_wait = tokio::time::interval(Duration::from_secs(1));
let shared_state = shared_state.clone(); let shared_state = shared_state.clone();
async move { async move {
loop { loop {
min_delay.tick().await; startup_wait.tick().await;
if !shared_state.read().unwrap().one_snapshot_done { if !shared_state.read().unwrap().one_snapshot_done {
continue; continue;
} }
@ -532,10 +532,11 @@ async fn main() -> anyhow::Result<()> {
let token_indexes = token_swap_info_updater let token_indexes = token_swap_info_updater
.mango_client() .mango_client()
.context .context
.token_indexes_by_name .tokens
.values() .keys()
.copied() .copied()
.collect_vec(); .collect_vec();
let mut min_delay = tokio::time::interval(Duration::from_secs(1));
for token_index in token_indexes { for token_index in token_indexes {
min_delay.tick().await; min_delay.tick().await;
match token_swap_info_updater.update_one(token_index).await { match token_swap_info_updater.update_one(token_index).await {