From 3d353340dc1db9683bb8ac90e2f6ed8eb2f63ce3 Mon Sep 17 00:00:00 2001 From: noot <36753753+noot@users.noreply.github.com> Date: Wed, 3 May 2023 14:59:46 -0400 Subject: [PATCH] fix: run t1 handler on xmrmaker ongoing swap restart (#457) --- protocol/xmrmaker/message_handler.go | 7 +++++++ protocol/xmrmaker/swap_state.go | 2 ++ 2 files changed, 9 insertions(+) diff --git a/protocol/xmrmaker/message_handler.go b/protocol/xmrmaker/message_handler.go index 04fdfb03..d68e116d 100644 --- a/protocol/xmrmaker/message_handler.go +++ b/protocol/xmrmaker/message_handler.go @@ -192,6 +192,13 @@ func (s *swapState) runT1ExpirationHandler() { time.Until(s.t1).Seconds(), ) + if time.Until(s.t2) < 0 { + log.Debugf("t2 (%s) has already passed; not starting t1 expiration handler", + s.t2.Format(common.TimeFmtSecs), + ) + return + } + waitCtx, waitCtxCancel := context.WithCancel(context.Background()) defer waitCtxCancel() // Unblock WaitForTimestamp if still running when we exit diff --git a/protocol/xmrmaker/swap_state.go b/protocol/xmrmaker/swap_state.go index d3d10fec..7c7c504b 100644 --- a/protocol/xmrmaker/swap_state.go +++ b/protocol/xmrmaker/swap_state.go @@ -317,6 +317,8 @@ func newSwapStateFromOngoing( s.pubkeys = sk.PublicKeyPair() s.contractSwapID = ethSwapInfo.SwapID s.contractSwap = ethSwapInfo.Swap + + go s.runT1ExpirationHandler() return s, nil }