From 1af0623c852f926e237297ea77c4251e4b9dfd7c Mon Sep 17 00:00:00 2001 From: Thomas Eizinger Date: Wed, 18 Aug 2021 12:35:47 +1000 Subject: [PATCH 1/2] Remove empty modules --- swap/src/network.rs | 2 -- swap/src/network/alice.rs | 1 - swap/src/network/bob.rs | 1 - 3 files changed, 4 deletions(-) delete mode 100644 swap/src/network/alice.rs delete mode 100644 swap/src/network/bob.rs diff --git a/swap/src/network.rs b/swap/src/network.rs index 420480af..22243783 100644 --- a/swap/src/network.rs +++ b/swap/src/network.rs @@ -1,7 +1,5 @@ mod impl_from_rr_event; -pub mod alice; -pub mod bob; pub mod cbor_request_response; pub mod encrypted_signature; pub mod json_pull_codec; diff --git a/swap/src/network/alice.rs b/swap/src/network/alice.rs deleted file mode 100644 index 8b137891..00000000 --- a/swap/src/network/alice.rs +++ /dev/null @@ -1 +0,0 @@ - diff --git a/swap/src/network/bob.rs b/swap/src/network/bob.rs deleted file mode 100644 index 8b137891..00000000 --- a/swap/src/network/bob.rs +++ /dev/null @@ -1 +0,0 @@ - From 6c446825b7570fbd508f74d59770571368cafb35 Mon Sep 17 00:00:00 2001 From: Thomas Eizinger Date: Wed, 18 Aug 2021 12:39:06 +1000 Subject: [PATCH 2/2] Instruct `Ping` to keep the connection alive --- CHANGELOG.md | 7 +++++++ swap/src/asb/network.rs | 4 ++-- swap/src/cli/behaviour.rs | 4 ++-- 3 files changed, 11 insertions(+), 4 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 202e10db..4e6a0655 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -7,6 +7,13 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ## [Unreleased] +### Fixed + +- An issue where the connection between ASB and CLI would get closed prematurely. + The CLI expects to be connected to the ASB throughout the entire swap and hence reconnects as soon as the connection is closed. + This resulted in a loop of connections being established but instantly closed again because the ASB deemed the connection to not be necessary. + See issue https://github.com/comit-network/xmr-btc-swap/issues/648. + ## [0.8.1] - 2021-08-16 ### Fixed diff --git a/swap/src/asb/network.rs b/swap/src/asb/network.rs index 1ae68d90..62c342e5 100644 --- a/swap/src/asb/network.rs +++ b/swap/src/asb/network.rs @@ -13,7 +13,7 @@ use libp2p::core::connection::ConnectionId; use libp2p::core::muxing::StreamMuxerBox; use libp2p::core::transport::Boxed; use libp2p::dns::TokioDnsConfig; -use libp2p::ping::{Ping, PingEvent}; +use libp2p::ping::{Ping, PingConfig, PingEvent}; use libp2p::request_response::{RequestId, ResponseChannel}; use libp2p::swarm::{ DialPeerCondition, IntoProtocolsHandler, NetworkBehaviour, NetworkBehaviourAction, @@ -152,7 +152,7 @@ pub mod behaviour { ), transfer_proof: transfer_proof::alice(), encrypted_signature: encrypted_signature::alice(), - ping: Ping::default(), + ping: Ping::new(PingConfig::new().with_keep_alive(true)), } } } diff --git a/swap/src/cli/behaviour.rs b/swap/src/cli/behaviour.rs index cbd39b27..716b7951 100644 --- a/swap/src/cli/behaviour.rs +++ b/swap/src/cli/behaviour.rs @@ -5,7 +5,7 @@ use crate::protocol::bob::State2; use crate::{bitcoin, env}; use anyhow::{anyhow, Error, Result}; use libp2p::core::Multiaddr; -use libp2p::ping::{Ping, PingEvent}; +use libp2p::ping::{Ping, PingConfig, PingEvent}; use libp2p::request_response::{RequestId, ResponseChannel}; use libp2p::{NetworkBehaviour, PeerId}; use std::sync::Arc; @@ -83,7 +83,7 @@ impl Behaviour { transfer_proof: transfer_proof::bob(), encrypted_signature: encrypted_signature::bob(), redial: redial::Behaviour::new(alice, Duration::from_secs(2)), - ping: Ping::default(), + ping: Ping::new(PingConfig::new().with_keep_alive(true)), } }