mirror of
https://github.com/lightninglabs/loop.git
synced 2026-08-13 12:33:03 +02:00
loopin: extract persistState
This commit is contained in:
parent
6b8fcc547c
commit
e33d2fb762
1 changed files with 12 additions and 8 deletions
20
loopin.go
20
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()
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue