Skip to content

staticaddr: minor fixes #956

New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
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
11 changes: 7 additions & 4 deletions staticaddr/deposit/manager.go
Original file line number Diff line number Diff line change
Expand Up @@ -191,10 +191,13 @@ func (m *Manager) recoverDeposits(ctx context.Context) error {
}

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

m.mu.Lock()
m.activeDeposits[d.OutPoint] = fsm
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)
}

return nil
Expand Down