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 | 20 ++++++++++++-------- 1 file changed, 12 insertions(+), 8 deletions(-) diff --git a/loopin.go b/loopin.go index 2ee6fa9a..bc0fcc34 100644 --- a/loopin.go +++ b/loopin.go @@ -694,14 +694,7 @@ 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( - s.hash, s.lastUpdateTime, - loopdb.SwapStateData{ - State: s.state, - Cost: s.cost, - }, - ) - if err != nil { + if err := s.persistState(); err != nil { return err } @@ -709,6 +702,17 @@ func (s *loopInSwap) persistAndAnnounceState(ctx context.Context) error { 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, + }, + ) +} + // setState updates the swap state and last update timestamp. func (s *loopInSwap) setState(state loopdb.SwapState) { s.lastUpdateTime = time.Now()