From e33d2fb7628497fd9f774a23ebe280f6d96ea06b Mon Sep 17 00:00:00 2001 From: Joost Jager Date: Thu, 25 Jun 2020 13:15:58 +0200 Subject: [PATCH] loopin: extract persistState --- loopin.go | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) diff --git a/loopin.go b/loopin.go index 2ee6fa9..bc0fcc3 100644 --- a/loopin.go +++ b/loopin.go @@ -694,19 +694,23 @@ func (s *loopInSwap) publishTimeoutTx(ctx context.Context, // update notification. func (s *loopInSwap) persistAndAnnounceState(ctx context.Context) error { // Update state in store. - err := s.store.UpdateLoopIn( + if err := s.persistState(); err != nil { + return err + } + + // Send out swap update + return s.sendUpdate(ctx) +} + +// persistState updates the swap state on disk. +func (s *loopInSwap) persistState() error { + return s.store.UpdateLoopIn( s.hash, s.lastUpdateTime, loopdb.SwapStateData{ State: s.state, Cost: s.cost, }, ) - if err != nil { - return err - } - - // Send out swap update - return s.sendUpdate(ctx) } // setState updates the swap state and last update timestamp.