Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 0 additions & 15 deletions staticaddr/deposit/actions.go
Original file line number Diff line number Diff line change
Expand Up @@ -137,21 +137,6 @@ func (f *FSM) WaitForExpirySweepAction(ctx context.Context,
}
}

// SweptExpiredDepositAction is the final action of the FSM. It signals to the
// manager that the deposit has been swept and the FSM can be removed. It also
// ends the state machine main loop by cancelling its context.
func (f *FSM) SweptExpiredDepositAction(ctx context.Context,
_ fsm.EventContext) fsm.EventType {

select {
case <-ctx.Done():
return fsm.OnError

case f.finalizedDepositChan <- f.deposit.OutPoint:
return fsm.NoOp
}
}

// FinalizeDepositAction is the final action after a withdrawal. It signals to
// the manager that the deposit has been swept and the FSM can be removed.
func (f *FSM) FinalizeDepositAction(ctx context.Context,
Expand Down
2 changes: 1 addition & 1 deletion staticaddr/deposit/fsm.go
Original file line number Diff line number Diff line change
Expand Up @@ -292,7 +292,7 @@ func (f *FSM) DepositStatesV0() fsm.States {
Transitions: fsm.Transitions{
OnExpiry: Expired,
},
Action: f.SweptExpiredDepositAction,
Action: f.FinalizeDepositAction,
},
Withdrawing: fsm.State{
Transitions: fsm.Transitions{
Expand Down
7 changes: 3 additions & 4 deletions staticaddr/loopin/manager.go
Original file line number Diff line number Diff line change
Expand Up @@ -473,16 +473,15 @@ func (m *Manager) recoverLoopIns(ctx context.Context) error {
}

// Send the OnRecover event to the state machine.
swapHash := loopIn.SwapHash
go func() {
err = fsm.SendEvent(ctx, OnRecover, nil)
go func(fsm *FSM, swapHash lntypes.Hash) {
err := fsm.SendEvent(ctx, OnRecover, nil)
if err != nil {
log.Errorf("Error sending OnStart event: %v",
err)
}

m.activeLoopIns[swapHash] = fsm
}()
}(fsm, loopIn.SwapHash)

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why is this needed? fsm and swapHash are a local variable and they can't change outside of the goroutine.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

loopIn is a iteration variable which might change before the goroutine launches, so this is needed.

}

return nil
Expand Down