Timeout Bob's execution-setup after 10 seconds

The execution setup is our only libp2p protocol that doesn't have
a timeout built-in. Hence, if anything fails on Alice's side, we
would wait here forever.

Wrapping the future in a timeout ensures that we fail eventually
if this protocol doesn't succeed.
pull/387/head
Thomas Eizinger 3 years ago
parent 5d75f1adba
commit dbe03ba1cf
No known key found for this signature in database
GPG Key ID: 651AC83A6C6C8B96

@ -5,6 +5,7 @@ use anyhow::{Context, Error, Result};
use libp2p::PeerId;
use libp2p_async_await::BehaviourOutEvent;
use std::sync::Arc;
use std::time::Duration;
#[derive(Debug)]
pub enum OutEvent {
@ -42,8 +43,8 @@ impl Behaviour {
state0: State0,
bitcoin_wallet: Arc<crate::bitcoin::Wallet>,
) {
self.inner
.do_protocol_dialer(alice, move |mut substream| async move {
self.inner.do_protocol_dialer(alice, move |mut substream| {
let protocol = async move {
tracing::debug!("Starting execution setup with {}", alice);
substream
@ -78,6 +79,9 @@ impl Behaviour {
.await?;
Ok(state2)
})
};
async move { tokio::time::timeout(Duration::from_secs(10), protocol).await? }
})
}
}

Loading…
Cancel
Save