mirror of
https://github.com/lightningnetwork/lnd.git
synced 2025-03-29 19:22:40 +01:00
htlcswitch+peer: pass BestHeight to ChannelLinkConfig
This allows non-test usages of ChannelLinkConfig to omit the raw htlcswitch.Switch pointer.
This commit is contained in:
parent
90db8de6fe
commit
6c6e353597
@ -134,6 +134,9 @@ type ChannelLinkConfig struct {
|
|||||||
// TODO(conner): remove after refactoring htlcswitch testing framework.
|
// TODO(conner): remove after refactoring htlcswitch testing framework.
|
||||||
Switch *Switch
|
Switch *Switch
|
||||||
|
|
||||||
|
// BestHeight returns the best known height.
|
||||||
|
BestHeight func() uint32
|
||||||
|
|
||||||
// ForwardPackets attempts to forward the batch of htlcs through the
|
// ForwardPackets attempts to forward the batch of htlcs through the
|
||||||
// switch. The function returns and error in case it fails to send one or
|
// switch. The function returns and error in case it fails to send one or
|
||||||
// more packets. The link's quit signal should be provided to allow
|
// more packets. The link's quit signal should be provided to allow
|
||||||
@ -2677,7 +2680,7 @@ func (l *channelLink) processRemoteAdds(fwdPkg *channeldb.FwdPkg,
|
|||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
|
|
||||||
heightNow := l.cfg.Switch.BestHeight()
|
heightNow := l.cfg.BestHeight()
|
||||||
|
|
||||||
pld, err := chanIterator.HopPayload()
|
pld, err := chanIterator.HopPayload()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
@ -1951,6 +1951,7 @@ func newSingleLinkTestHarness(chanAmt, chanReserve btcutil.Amount) (
|
|||||||
FwrdingPolicy: globalPolicy,
|
FwrdingPolicy: globalPolicy,
|
||||||
Peer: alicePeer,
|
Peer: alicePeer,
|
||||||
Switch: aliceSwitch,
|
Switch: aliceSwitch,
|
||||||
|
BestHeight: aliceSwitch.BestHeight,
|
||||||
Circuits: aliceSwitch.CircuitModifier(),
|
Circuits: aliceSwitch.CircuitModifier(),
|
||||||
ForwardPackets: aliceSwitch.ForwardPackets,
|
ForwardPackets: aliceSwitch.ForwardPackets,
|
||||||
DecodeHopIterators: decoder.DecodeHopIterators,
|
DecodeHopIterators: decoder.DecodeHopIterators,
|
||||||
@ -4454,6 +4455,7 @@ func (h *persistentLinkHarness) restartLink(
|
|||||||
FwrdingPolicy: globalPolicy,
|
FwrdingPolicy: globalPolicy,
|
||||||
Peer: alicePeer,
|
Peer: alicePeer,
|
||||||
Switch: aliceSwitch,
|
Switch: aliceSwitch,
|
||||||
|
BestHeight: aliceSwitch.BestHeight,
|
||||||
Circuits: aliceSwitch.CircuitModifier(),
|
Circuits: aliceSwitch.CircuitModifier(),
|
||||||
ForwardPackets: aliceSwitch.ForwardPackets,
|
ForwardPackets: aliceSwitch.ForwardPackets,
|
||||||
DecodeHopIterators: decoder.DecodeHopIterators,
|
DecodeHopIterators: decoder.DecodeHopIterators,
|
||||||
|
@ -1119,6 +1119,7 @@ func (h *hopNetwork) createChannelLink(server, peer *mockServer,
|
|||||||
link := NewChannelLink(
|
link := NewChannelLink(
|
||||||
ChannelLinkConfig{
|
ChannelLinkConfig{
|
||||||
Switch: server.htlcSwitch,
|
Switch: server.htlcSwitch,
|
||||||
|
BestHeight: server.htlcSwitch.BestHeight,
|
||||||
FwrdingPolicy: h.globalPolicy,
|
FwrdingPolicy: h.globalPolicy,
|
||||||
Peer: peer,
|
Peer: peer,
|
||||||
Circuits: server.htlcSwitch.CircuitModifier(),
|
Circuits: server.htlcSwitch.CircuitModifier(),
|
||||||
|
@ -813,7 +813,7 @@ func (p *Brontide) addLink(chanPoint *wire.OutPoint,
|
|||||||
FetchLastChannelUpdate: p.cfg.FetchLastChanUpdate,
|
FetchLastChannelUpdate: p.cfg.FetchLastChanUpdate,
|
||||||
HodlMask: p.cfg.Hodl.Mask(),
|
HodlMask: p.cfg.Hodl.Mask(),
|
||||||
Registry: p.cfg.Invoices,
|
Registry: p.cfg.Invoices,
|
||||||
Switch: p.cfg.Switch,
|
BestHeight: p.cfg.Switch.BestHeight,
|
||||||
Circuits: p.cfg.Switch.CircuitModifier(),
|
Circuits: p.cfg.Switch.CircuitModifier(),
|
||||||
ForwardPackets: p.cfg.InterceptSwitch.ForwardPackets,
|
ForwardPackets: p.cfg.InterceptSwitch.ForwardPackets,
|
||||||
FwrdingPolicy: *forwardingPolicy,
|
FwrdingPolicy: *forwardingPolicy,
|
||||||
|
Loading…
x
Reference in New Issue
Block a user