Remove timeout on send encrypted signature

Bob was timing out if the encrypted signature could not be sent in 60
seconds. This behaviour is unnecessary because we are racing against
the cancel timelock anyway. By timing out before this, we remove the
opportunity for bob and alice to re-establish a connection.
This commit is contained in:
rishflab 2021-08-31 15:21:44 +10:00
parent 8598bcade1
commit af50c655ae
2 changed files with 8 additions and 4 deletions

View File

@ -54,7 +54,7 @@ impl EventLoop {
) -> Result<(Self, EventLoopHandle)> {
let execution_setup = bmrng::channel_with_timeout(1, Duration::from_secs(60));
let transfer_proof = bmrng::channel_with_timeout(1, Duration::from_secs(60));
let encrypted_signature = bmrng::channel_with_timeout(1, Duration::from_secs(60));
let encrypted_signature = bmrng::channel(1);
let quote = bmrng::channel_with_timeout(1, Duration::from_secs(60));
let event_loop = EventLoop {
@ -248,7 +248,7 @@ impl EventLoopHandle {
pub async fn send_encrypted_signature(
&mut self,
tx_redeem_encsig: EncryptedSignature,
) -> Result<()> {
) -> Result<(), bmrng::error::RequestError<EncryptedSignature>> {
Ok(self
.encrypted_signature
.send_receive(tx_redeem_encsig)

View File

@ -176,8 +176,12 @@ async fn next_state(
// Bob sends Alice his key
select! {
_ = event_loop_handle.send_encrypted_signature(state.tx_redeem_encsig()) => {
BobState::EncSigSent(state)
result = event_loop_handle.send_encrypted_signature(state.tx_redeem_encsig()) => {
match result {
Ok(_) => BobState::EncSigSent(state),
Err(bmrng::error::RequestError::RecvError | bmrng::error::RequestError::SendError(_)) => bail!("Failed to communicate encrypted signature through event loop channel"),
Err(bmrng::error::RequestError::RecvTimeoutError) => unreachable!("We construct the channel with no timeout"),
}
},
result = tx_lock_status.wait_until_confirmed_with(state.cancel_timelock) => {
let _ = result?;