htlcswitch: add new LinkFailureAction enum

In this commit, we add a new LinkFailureAction enum to take over the old
force close bool. Force closing isn't the only thing we might want to do
when we decide to fail the link, so this is a prep refactoring for an
upcoming change.
This commit is contained in:
Olaoluwa Osuntokun
2023-05-19 17:16:25 -07:00
parent 7dacf5edb9
commit cb5fc71659
4 changed files with 33 additions and 21 deletions

View File

@@ -3094,11 +3094,10 @@ func (p *Brontide) handleLinkFailure(failure linkFailureReport) {
// being applied.
p.WipeChannel(&failure.chanPoint)
// If the error encountered was severe enough, we'll now force close the
// channel to prevent reading it to the switch in the future.
if failure.linkErr.ForceClose {
p.log.Warnf("Force closing link(%v)",
failure.shortChanID)
// If the error encountered was severe enough, we'll now force close
// the channel to prevent reading it to the switch in the future.
if failure.linkErr.FailureAction == htlcswitch.LinkFailureForceClose {
p.log.Warnf("Force closing link(%v)", failure.shortChanID)
closeTx, err := p.cfg.ChainArb.ForceCloseContract(
failure.chanPoint,