multi: link notifies subscribers of ActiveLinkEvent, rpc ignores
This commit is contained in:
parent
f5237589ea
commit
966cd2112c
@ -265,6 +265,10 @@ type ChannelLinkConfig struct {
|
|||||||
// initiator of the channel.
|
// initiator of the channel.
|
||||||
MaxFeeAllocation float64
|
MaxFeeAllocation float64
|
||||||
|
|
||||||
|
// NotifyActiveLink allows the link to tell the ChannelNotifier when a
|
||||||
|
// link is first started.
|
||||||
|
NotifyActiveLink func(wire.OutPoint)
|
||||||
|
|
||||||
// NotifyActiveChannel allows the link to tell the ChannelNotifier when
|
// NotifyActiveChannel allows the link to tell the ChannelNotifier when
|
||||||
// channels becomes active.
|
// channels becomes active.
|
||||||
NotifyActiveChannel func(wire.OutPoint)
|
NotifyActiveChannel func(wire.OutPoint)
|
||||||
@ -870,6 +874,10 @@ func (l *channelLink) htlcManager() {
|
|||||||
|
|
||||||
l.log.Infof("HTLC manager started, bandwidth=%v", l.Bandwidth())
|
l.log.Infof("HTLC manager started, bandwidth=%v", l.Bandwidth())
|
||||||
|
|
||||||
|
// Notify any clients that the link is now in the switch via an
|
||||||
|
// ActiveLinkEvent.
|
||||||
|
l.cfg.NotifyActiveLink(*l.ChannelPoint())
|
||||||
|
|
||||||
// TODO(roasbeef): need to call wipe chan whenever D/C?
|
// TODO(roasbeef): need to call wipe chan whenever D/C?
|
||||||
|
|
||||||
// If this isn't the first time that this channel link has been
|
// If this isn't the first time that this channel link has been
|
||||||
|
@ -1748,6 +1748,7 @@ func newSingleLinkTestHarness(chanAmt, chanReserve btcutil.Amount) (
|
|||||||
MaxFeeUpdateTimeout: 40 * time.Minute,
|
MaxFeeUpdateTimeout: 40 * time.Minute,
|
||||||
MaxOutgoingCltvExpiry: DefaultMaxOutgoingCltvExpiry,
|
MaxOutgoingCltvExpiry: DefaultMaxOutgoingCltvExpiry,
|
||||||
MaxFeeAllocation: DefaultMaxLinkFeeAllocation,
|
MaxFeeAllocation: DefaultMaxLinkFeeAllocation,
|
||||||
|
NotifyActiveLink: func(wire.OutPoint) {},
|
||||||
NotifyActiveChannel: func(wire.OutPoint) {},
|
NotifyActiveChannel: func(wire.OutPoint) {},
|
||||||
NotifyInactiveChannel: func(wire.OutPoint) {},
|
NotifyInactiveChannel: func(wire.OutPoint) {},
|
||||||
HtlcNotifier: aliceSwitch.cfg.HtlcNotifier,
|
HtlcNotifier: aliceSwitch.cfg.HtlcNotifier,
|
||||||
@ -4474,6 +4475,7 @@ func (h *persistentLinkHarness) restartLink(
|
|||||||
HodlMask: hodl.MaskFromFlags(hodlFlags...),
|
HodlMask: hodl.MaskFromFlags(hodlFlags...),
|
||||||
MaxOutgoingCltvExpiry: DefaultMaxOutgoingCltvExpiry,
|
MaxOutgoingCltvExpiry: DefaultMaxOutgoingCltvExpiry,
|
||||||
MaxFeeAllocation: DefaultMaxLinkFeeAllocation,
|
MaxFeeAllocation: DefaultMaxLinkFeeAllocation,
|
||||||
|
NotifyActiveLink: func(wire.OutPoint) {},
|
||||||
NotifyActiveChannel: func(wire.OutPoint) {},
|
NotifyActiveChannel: func(wire.OutPoint) {},
|
||||||
NotifyInactiveChannel: func(wire.OutPoint) {},
|
NotifyInactiveChannel: func(wire.OutPoint) {},
|
||||||
HtlcNotifier: aliceSwitch.cfg.HtlcNotifier,
|
HtlcNotifier: aliceSwitch.cfg.HtlcNotifier,
|
||||||
|
@ -1173,6 +1173,7 @@ func (h *hopNetwork) createChannelLink(server, peer *mockServer,
|
|||||||
OutgoingCltvRejectDelta: 3,
|
OutgoingCltvRejectDelta: 3,
|
||||||
MaxOutgoingCltvExpiry: DefaultMaxOutgoingCltvExpiry,
|
MaxOutgoingCltvExpiry: DefaultMaxOutgoingCltvExpiry,
|
||||||
MaxFeeAllocation: DefaultMaxLinkFeeAllocation,
|
MaxFeeAllocation: DefaultMaxLinkFeeAllocation,
|
||||||
|
NotifyActiveLink: func(wire.OutPoint) {},
|
||||||
NotifyActiveChannel: func(wire.OutPoint) {},
|
NotifyActiveChannel: func(wire.OutPoint) {},
|
||||||
NotifyInactiveChannel: func(wire.OutPoint) {},
|
NotifyInactiveChannel: func(wire.OutPoint) {},
|
||||||
HtlcNotifier: server.htlcSwitch.cfg.HtlcNotifier,
|
HtlcNotifier: server.htlcSwitch.cfg.HtlcNotifier,
|
||||||
|
2
peer.go
2
peer.go
@ -21,6 +21,7 @@ import (
|
|||||||
"github.com/lightningnetwork/lnd/buffer"
|
"github.com/lightningnetwork/lnd/buffer"
|
||||||
"github.com/lightningnetwork/lnd/chainntnfs"
|
"github.com/lightningnetwork/lnd/chainntnfs"
|
||||||
"github.com/lightningnetwork/lnd/channeldb"
|
"github.com/lightningnetwork/lnd/channeldb"
|
||||||
|
"github.com/lightningnetwork/lnd/channelnotifier"
|
||||||
"github.com/lightningnetwork/lnd/contractcourt"
|
"github.com/lightningnetwork/lnd/contractcourt"
|
||||||
"github.com/lightningnetwork/lnd/feature"
|
"github.com/lightningnetwork/lnd/feature"
|
||||||
"github.com/lightningnetwork/lnd/htlcswitch"
|
"github.com/lightningnetwork/lnd/htlcswitch"
|
||||||
@ -649,6 +650,7 @@ func (p *peer) addLink(chanPoint *wire.OutPoint,
|
|||||||
TowerClient: p.server.towerClient,
|
TowerClient: p.server.towerClient,
|
||||||
MaxOutgoingCltvExpiry: cfg.MaxOutgoingCltvExpiry,
|
MaxOutgoingCltvExpiry: cfg.MaxOutgoingCltvExpiry,
|
||||||
MaxFeeAllocation: cfg.MaxChannelFeeAllocation,
|
MaxFeeAllocation: cfg.MaxChannelFeeAllocation,
|
||||||
|
NotifyActiveLink: p.server.channelNotifier.NotifyActiveLinkEvent,
|
||||||
NotifyActiveChannel: p.server.channelNotifier.NotifyActiveChannelEvent,
|
NotifyActiveChannel: p.server.channelNotifier.NotifyActiveChannelEvent,
|
||||||
NotifyInactiveChannel: p.server.channelNotifier.NotifyInactiveChannelEvent,
|
NotifyInactiveChannel: p.server.channelNotifier.NotifyInactiveChannelEvent,
|
||||||
HtlcNotifier: p.server.htlcNotifier,
|
HtlcNotifier: p.server.htlcNotifier,
|
||||||
|
@ -3522,6 +3522,11 @@ func (r *rpcServer) SubscribeChannelEvents(req *lnrpc.ChannelEventSubscription,
|
|||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Completely ignore ActiveLinkEvent as this is explicitly not
|
||||||
|
// exposed to the RPC.
|
||||||
|
case channelnotifier.ActiveLinkEvent:
|
||||||
|
continue
|
||||||
|
|
||||||
default:
|
default:
|
||||||
return fmt.Errorf("unexpected channel event update: %v", event)
|
return fmt.Errorf("unexpected channel event update: %v", event)
|
||||||
}
|
}
|
||||||
@ -5896,6 +5901,8 @@ func (r *rpcServer) SubscribeChannelBackups(req *lnrpc.ChannelBackupSubscription
|
|||||||
continue
|
continue
|
||||||
case channelnotifier.InactiveChannelEvent:
|
case channelnotifier.InactiveChannelEvent:
|
||||||
continue
|
continue
|
||||||
|
case channelnotifier.ActiveLinkEvent:
|
||||||
|
continue
|
||||||
}
|
}
|
||||||
|
|
||||||
// Now that we know the channel state has changed,
|
// Now that we know the channel state has changed,
|
||||||
|
Loading…
Reference in New Issue
Block a user