From 77fc16d21158c6542addcbaaff47b801d3b5f5c7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Roman=20Smr=C5=BE?= Date: Sat, 17 Dec 2022 20:10:20 +0100 Subject: Confirm pairing outcome after head commit --- src/pairing.cpp | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) (limited to 'src/pairing.cpp') diff --git a/src/pairing.cpp b/src/pairing.cpp index f25cb5c..c22a7af 100644 --- a/src/pairing.cpp +++ b/src/pairing.cpp @@ -147,7 +147,9 @@ void PairingServiceBase::handle(Context & ctx) requestNonceFailedHook(ctx.peer()); if (state->phase < StatePhase::PairingDone) { state->phase = StatePhase::PairingFailed; - state->outcome.set_value(Outcome::NonceMismatch); + ctx.afterCommit([&]() { + state->outcome.set_value(Outcome::NonceMismatch); + }); } return; } @@ -166,7 +168,9 @@ void PairingServiceBase::handle(Context & ctx) else if (auto reject = rec->item("reject").asText()) { if (state->phase < StatePhase::PairingDone) { state->phase = StatePhase::PairingFailed; - state->outcome.set_value(Outcome::PeerRejected); + ctx.afterCommit([&]() { + state->outcome.set_value(Outcome::PeerRejected); + }); } } @@ -174,7 +178,9 @@ void PairingServiceBase::handle(Context & ctx) if (state->phase == StatePhase::OurRequestReady) { handlePairingResult(ctx); state->phase = StatePhase::PairingDone; - state->outcome.set_value(Outcome::Success); + ctx.afterCommit([&]() { + state->outcome.set_value(Outcome::Success); + }); } else { result = ctx.ref(); } -- cgit v1.2.3