Browse Source
Introduce drop-in replacement for tokio::spawn that logs errors
Otherwise, any errors occurring within these tasks are silently
ignored.
refactor/no-log-handler
Thomas Eizinger
3 years ago
No known key found for this signature in database
GPG Key ID: 651AC83A6C6C8B96
4 changed files with
18 additions and
1 deletions
-
daemon/src/maker.rs
-
daemon/src/oracle.rs
-
daemon/src/taker.rs
-
daemon/src/tokio_ext.rs
|
@ -42,6 +42,7 @@ mod seed; |
|
|
mod send_to_socket; |
|
|
mod send_to_socket; |
|
|
mod setup_contract; |
|
|
mod setup_contract; |
|
|
mod to_sse_event; |
|
|
mod to_sse_event; |
|
|
|
|
|
mod tokio_ext; |
|
|
mod wallet; |
|
|
mod wallet; |
|
|
mod wallet_sync; |
|
|
mod wallet_sync; |
|
|
mod wire; |
|
|
mod wire; |
|
|
|
@ -1,6 +1,7 @@ |
|
|
use crate::actors::log_error; |
|
|
use crate::actors::log_error; |
|
|
use crate::model::cfd::{Cfd, CfdState}; |
|
|
use crate::model::cfd::{Cfd, CfdState}; |
|
|
use crate::model::BitMexPriceEventId; |
|
|
use crate::model::BitMexPriceEventId; |
|
|
|
|
|
use crate::tokio_ext; |
|
|
use anyhow::{Context, Result}; |
|
|
use anyhow::{Context, Result}; |
|
|
use async_trait::async_trait; |
|
|
use async_trait::async_trait; |
|
|
use cfd_protocol::secp256k1_zkp::{schnorrsig, SecretKey}; |
|
|
use cfd_protocol::secp256k1_zkp::{schnorrsig, SecretKey}; |
|
@ -111,7 +112,7 @@ where |
|
|
|
|
|
|
|
|
for event_id in self.pending_announcements.iter().cloned() { |
|
|
for event_id in self.pending_announcements.iter().cloned() { |
|
|
let this = this.clone(); |
|
|
let this = this.clone(); |
|
|
tokio::spawn(async move { |
|
|
tokio_ext::spawn_fallible(async move { |
|
|
let url = event_id.to_olivia_url(); |
|
|
let url = event_id.to_olivia_url(); |
|
|
|
|
|
|
|
|
tracing::debug!("Fetching announcement for {}", event_id); |
|
|
tracing::debug!("Fetching announcement for {}", event_id); |
|
|
|
@ -42,6 +42,7 @@ mod send_to_socket; |
|
|
mod setup_contract; |
|
|
mod setup_contract; |
|
|
mod taker_cfd; |
|
|
mod taker_cfd; |
|
|
mod to_sse_event; |
|
|
mod to_sse_event; |
|
|
|
|
|
mod tokio_ext; |
|
|
mod wallet; |
|
|
mod wallet; |
|
|
mod wallet_sync; |
|
|
mod wallet_sync; |
|
|
mod wire; |
|
|
mod wire; |
|
|
|
@ -0,0 +1,14 @@ |
|
|
|
|
|
use std::fmt; |
|
|
|
|
|
use std::future::Future; |
|
|
|
|
|
|
|
|
|
|
|
pub fn spawn_fallible<F, E>(future: F) |
|
|
|
|
|
where |
|
|
|
|
|
F: Future<Output = Result<(), E>> + Send + 'static, |
|
|
|
|
|
E: fmt::Display, |
|
|
|
|
|
{ |
|
|
|
|
|
tokio::spawn(async move { |
|
|
|
|
|
if let Err(e) = future.await { |
|
|
|
|
|
tracing::warn!("Task failed: {:#}", e); |
|
|
|
|
|
} |
|
|
|
|
|
}); |
|
|
|
|
|
} |