Do not actively set KeepAlice::No for swap_setup

Closing the connection upon completing the `swap_setup` protocol caused problems on the ASB side, because the CLI would close the connection before the last message was properly processed. This would result in swaps going into execution on the CLI side, but not on the ASB side.
The CLI ensures an open connection to the ASB over the complete course of a swap. So it does not make much sense to allow a protocol to close the connection (the CLI would immediately redial).
For the Alice we set the initial `KeepAlive` to `10` seconds because Bob is expected to request a spot price in reasonable time after opening a connection on the protocol. Since Tor connections can take some time we set 10 seconds fow now for resilience.
This commit is contained in:
Daniel Karzel 2021-06-28 11:53:46 +10:00
parent cd14e22cdf
commit dc89a837e7
No known key found for this signature in database
GPG Key ID: 30C3FC2E438ADB6E
2 changed files with 3 additions and 5 deletions

View File

@ -228,7 +228,7 @@ impl<LR> Handler<LR> {
latest_rate,
resume_only,
timeout: Duration::from_secs(120),
keep_alive: KeepAlive::Until(Instant::now() + Duration::from_secs(5)),
keep_alive: KeepAlive::Until(Instant::now() + Duration::from_secs(10)),
}
}
}
@ -445,7 +445,6 @@ where
}
if let Some(result) = futures::ready!(self.inbound_stream.poll_unpin(cx)) {
self.keep_alive = KeepAlive::No;
self.inbound_stream = OptionFuture::from(None);
return Poll::Ready(ProtocolsHandlerEvent::Custom(HandlerOutEvent::Completed(
result,

View File

@ -19,7 +19,7 @@ use libp2p::{Multiaddr, PeerId};
use std::collections::VecDeque;
use std::sync::Arc;
use std::task::{Context, Poll};
use std::time::{Duration, Instant};
use std::time::Duration;
use uuid::Uuid;
use void::Void;
@ -112,7 +112,7 @@ impl Handler {
timeout: Duration::from_secs(120),
new_swaps: VecDeque::default(),
bitcoin_wallet,
keep_alive: KeepAlive::Until(Instant::now() + Duration::from_secs(5)),
keep_alive: KeepAlive::Yes,
}
}
}
@ -240,7 +240,6 @@ impl ProtocolsHandler for Handler {
}
if let Some(result) = futures::ready!(self.outbound_stream.poll_unpin(cx)) {
self.keep_alive = KeepAlive::No;
self.outbound_stream = OptionFuture::from(None);
return Poll::Ready(ProtocolsHandlerEvent::Custom(Completed(result)));
}