peer: conditionally create new RBF chan closer
This commit is contained in:
1 parent
4fff0d8401
commit
f22cba9de1
1 file changed
+16
-1
+16
-1
@@ -457,6 +457,12 @@ func makeNegotiateCloser(chanCloser *chancloser.ChanCloser) chanCloserFsm {
|
|||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func makeRbfCloser(rbfCloser *chancloser.RbfChanCloser) chanCloserFsm {
|
||||||
|
return fn.NewRight[*chancloser.ChanCloser](
|
||||||
|
rbfCloser,
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
// Brontide is an active peer on the Lightning Network. This struct is responsible
|
// Brontide is an active peer on the Lightning Network. This struct is responsible
|
||||||
// for managing any channel state related to this peer. To do so, it has
|
// for managing any channel state related to this peer. To do so, it has
|
||||||
// several helper goroutines to handle events such as HTLC timeouts, new
|
// several helper goroutines to handle events such as HTLC timeouts, new
|
||||||
@@ -3586,6 +3592,8 @@ func (p *Brontide) initRbfChanCloser(
|
|||||||
|
|
||||||
chanCloser := protofsm.NewStateMachine(protoCfg)
|
chanCloser := protofsm.NewStateMachine(protoCfg)
|
||||||
|
|
||||||
|
p.activeChanCloses[chanID] = makeRbfCloser(&chanCloser)
|
||||||
|
|
||||||
// Now that we've created the channel state machine, we'll register for
|
// Now that we've created the channel state machine, we'll register for
|
||||||
// a hook to be sent once the channel has been flushed.
|
// a hook to be sent once the channel has been flushed.
|
||||||
link.OnFlushedOnce(func() {
|
link.OnFlushedOnce(func() {
|
||||||
@@ -3652,7 +3660,14 @@ func (p *Brontide) handleLocalCloseReq(req *htlcswitch.ChanClose) {
|
|||||||
// out this channel on-chain, so we execute the cooperative channel
|
// out this channel on-chain, so we execute the cooperative channel
|
||||||
// closure workflow.
|
// closure workflow.
|
||||||
case contractcourt.CloseRegular:
|
case contractcourt.CloseRegular:
|
||||||
err := p.initNegotiateChanCloser(req, channel)
|
var err error
|
||||||
|
switch {
|
||||||
|
case p.rbfCoopCloseAllowed():
|
||||||
|
err = p.initAndStartRbfChanCloser(req, channel)
|
||||||
|
default:
|
||||||
|
err = p.initNegotiateChanCloser(req, channel)
|
||||||
|
}
|
||||||
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
p.log.Errorf(err.Error())
|
p.log.Errorf(err.Error())
|
||||||
req.Err <- err
|
req.Err <- err
|
||||||
|
|||||||
Reference in new issue
Block a user