From 23c2d5864785ba7e1671547838fa873b4791ac81 Mon Sep 17 00:00:00 2001 From: Giulio De Pasquale Date: Thu, 14 Jan 2021 12:46:35 +0000 Subject: [PATCH] correct loop (not ignoring first tick). grouped together managers update --- rustybot/src/bot.rs | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/rustybot/src/bot.rs b/rustybot/src/bot.rs index 899b543..6743af7 100644 --- a/rustybot/src/bot.rs +++ b/rustybot/src/bot.rs @@ -62,16 +62,26 @@ impl BfxBot { } pub async fn start_loop(&mut self) -> Result<(), BoxError> { + self.update_managers().await?; + loop { self.update().await; } } - async fn update(&mut self) { + async fn update(&mut self) -> Result<(), BoxError> { delay_for(self.ticker.duration()).await; self.ticker.inc(); - self.update_price_managers().await.unwrap(); + self.update_managers().await?; + + Ok(()) + } + + async fn update_managers(&mut self) -> Result<(), BoxError> { + self.update_price_managers().await?; + + Ok(()) } async fn update_price_managers(&mut self) -> Result>, BoxError> {