Skip to content

Commit

Permalink
chore: Send failed taks status on timeout for rollover
Browse files Browse the repository at this point in the history
  • Loading branch information
holzeis committed Sep 14, 2023
1 parent 2444340 commit 38bf276
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions mobile/native/src/orderbook.rs
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ use uuid::Uuid;

const WS_RECONNECT_TIMEOUT: Duration = Duration::from_secs(2);
const EXPIRED_ORDER_PRUNING_INTERVAL: Duration = Duration::from_secs(30);
const ROLLOVER_PROTOCOL_TIMEOUT: Duration = Duration::from_secs(60);

pub fn subscribe(
secret_key: SecretKey,
Expand Down Expand Up @@ -109,6 +110,15 @@ pub fn subscribe(
tracing::info!("Received a rollover request from orderbook.");
event::publish(&EventInternal::BackgroundNotification(BackgroundTask::Rollover(TaskStatus::Pending)));

// Sending a failed event with a delay. This event will be ignored by the UI if the task has
// been successful in the meantime.
tokio::spawn(async {
tokio::time::sleep(ROLLOVER_PROTOCOL_TIMEOUT).await;
event::publish(&EventInternal::BackgroundNotification(
BackgroundTask::RecoverDlc(TaskStatus::Failed),
));
});

if let Err(e) = position::handler::rollover().await {
tracing::error!("Failed to rollover dlc. Error: {e:#}");
event::publish(&EventInternal::BackgroundNotification(BackgroundTask::Rollover(TaskStatus::Failed)));
Expand Down

0 comments on commit 38bf276

Please sign in to comment.