mirror of
https://github.com/lightningnetwork/lnd.git
synced 2025-03-26 01:33:02 +01:00
peer: attempt to unregister endpoint before registering
If we hit an error, we want to wipe the state machine state, which also includes removing the old endpoint.
This commit is contained in:
parent
029fbd22fd
commit
282c50e444
@ -3627,6 +3627,9 @@ func newChanErrorReporter(chanID lnwire.ChannelID,
|
||||
//
|
||||
// This is a part of the chancloser.ErrorReporter interface.
|
||||
func (c *chanErrorReporter) ReportError(chanErr error) {
|
||||
c.peer.log.Errorf("coop close error for channel %v: %v",
|
||||
c.chanID, chanErr)
|
||||
|
||||
var errMsg []byte
|
||||
if errors.Is(chanErr, chancloser.ErrInvalidStateTransition) {
|
||||
errMsg = []byte("unexpected protocol message")
|
||||
@ -3822,6 +3825,8 @@ func (p *Brontide) initRbfChanCloser(
|
||||
// Finally, we'll register this new endpoint with the message router so
|
||||
// future co-op close messages are handled by this state machine.
|
||||
err = fn.MapOptionZ(p.msgRouter, func(r msgmux.Router) error {
|
||||
_ = r.UnregisterEndpoint(chanCloser.Name())
|
||||
|
||||
return r.RegisterEndpoint(&chanCloser)
|
||||
})
|
||||
if err != nil {
|
||||
|
Loading…
x
Reference in New Issue
Block a user