Skip to content

Commit e33d2fb

Browse files
committed
loopin: extract persistState
1 parent 6b8fcc5 commit e33d2fb

File tree

1 file changed

+11
-7
lines changed

1 file changed

+11
-7
lines changed

loopin.go

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -694,19 +694,23 @@ func (s *loopInSwap) publishTimeoutTx(ctx context.Context,
694694
// update notification.
695695
func (s *loopInSwap) persistAndAnnounceState(ctx context.Context) error {
696696
// Update state in store.
697-
err := s.store.UpdateLoopIn(
697+
if err := s.persistState(); err != nil {
698+
return err
699+
}
700+
701+
// Send out swap update
702+
return s.sendUpdate(ctx)
703+
}
704+
705+
// persistState updates the swap state on disk.
706+
func (s *loopInSwap) persistState() error {
707+
return s.store.UpdateLoopIn(
698708
s.hash, s.lastUpdateTime,
699709
loopdb.SwapStateData{
700710
State: s.state,
701711
Cost: s.cost,
702712
},
703713
)
704-
if err != nil {
705-
return err
706-
}
707-
708-
// Send out swap update
709-
return s.sendUpdate(ctx)
710714
}
711715

712716
// setState updates the swap state and last update timestamp.

0 commit comments

Comments
 (0)