funding+lnd: make sure accessman won't interrupt funding flow

If there's an error occured when updating the peer's status after the
channel status is changed, we now make sure we log the error instead of
letting it interrupt the channel open/close flow.
This commit is contained in:
yyforyongyu
2025-06-17 22:46:37 +08:00
parent 0dc10ba692
commit 03de0f9e4b
3 changed files with 29 additions and 51 deletions

View File

@@ -4279,43 +4279,48 @@ func (s *server) SubscribeCustomMessages() (*subscribe.Client, error) {
// notifyOpenChannelPeerEvent updates the access manager's maps and then calls
// the channelNotifier's NotifyOpenChannelEvent.
func (s *server) notifyOpenChannelPeerEvent(op wire.OutPoint,
remotePub *btcec.PublicKey) error {
remotePub *btcec.PublicKey) {
// Call newOpenChan to update the access manager's maps for this peer.
if err := s.peerAccessMan.newOpenChan(remotePub); err != nil {
return err
srvrLog.Errorf("Failed to update peer[%x] access status after "+
"channel[%v] open", remotePub.SerializeCompressed(), op)
}
// Notify subscribers about this open channel event.
s.channelNotifier.NotifyOpenChannelEvent(op)
return nil
}
// notifyPendingOpenChannelPeerEvent updates the access manager's maps and then
// calls the channelNotifier's NotifyPendingOpenChannelEvent.
func (s *server) notifyPendingOpenChannelPeerEvent(op wire.OutPoint,
pendingChan *channeldb.OpenChannel, remotePub *btcec.PublicKey) error {
pendingChan *channeldb.OpenChannel, remotePub *btcec.PublicKey) {
// Call newPendingOpenChan to update the access manager's maps for this
// peer.
if err := s.peerAccessMan.newPendingOpenChan(remotePub); err != nil {
return err
srvrLog.Errorf("Failed to update peer[%x] access status after "+
"channel[%v] pending open",
remotePub.SerializeCompressed(), op)
}
// Notify subscribers about this event.
s.channelNotifier.NotifyPendingOpenChannelEvent(op, pendingChan)
return nil
}
// notifyFundingTimeoutPeerEvent updates the access manager's maps and then
// calls the channelNotifier's NotifyFundingTimeout.
func (s *server) notifyFundingTimeoutPeerEvent(op wire.OutPoint,
remotePub *btcec.PublicKey) error {
remotePub *btcec.PublicKey) {
// Call newPendingCloseChan to potentially demote the peer.
err := s.peerAccessMan.newPendingCloseChan(remotePub)
if err != nil {
srvrLog.Errorf("Failed to update peer[%x] access status after "+
"channel[%v] pending close",
remotePub.SerializeCompressed(), op)
}
if errors.Is(err, ErrNoMoreRestrictedAccessSlots) {
// If we encounter an error while attempting to disconnect the
// peer, log the error.
@@ -4326,8 +4331,6 @@ func (s *server) notifyFundingTimeoutPeerEvent(op wire.OutPoint,
// Notify subscribers about this event.
s.channelNotifier.NotifyFundingTimeout(op)
return nil
}
// peerConnected is a function that handles initialization a newly connected