mirror of
https://github.com/lightningnetwork/lnd.git
synced 2025-07-01 02:51:37 +02:00
multi: move bandwidth hints behind interface
This commit is contained in:
31
server.go
31
server.go
@ -820,33 +820,6 @@ func newServer(cfg *Config, listenAddrs []net.Addr,
|
||||
return nil, err
|
||||
}
|
||||
|
||||
queryBandwidth := func(c *channeldb.DirectedChannel) lnwire.MilliSatoshi {
|
||||
cid := lnwire.NewShortChanIDFromInt(c.ChannelID)
|
||||
link, err := s.htlcSwitch.GetLinkByShortID(cid)
|
||||
if err != nil {
|
||||
// If the link isn't online, then we'll report
|
||||
// that it has zero bandwidth to the router.
|
||||
return 0
|
||||
}
|
||||
|
||||
// If the link is found within the switch, but it isn't
|
||||
// yet eligible to forward any HTLCs, then we'll treat
|
||||
// it as if it isn't online in the first place.
|
||||
if !link.EligibleToForward() {
|
||||
return 0
|
||||
}
|
||||
|
||||
// If our link isn't currently in a state where it can
|
||||
// add another outgoing htlc, treat the link as unusable.
|
||||
if err := link.MayAddOutgoingHtlc(); err != nil {
|
||||
return 0
|
||||
}
|
||||
|
||||
// Otherwise, we'll return the current best estimate
|
||||
// for the available bandwidth for the link.
|
||||
return link.Bandwidth()
|
||||
}
|
||||
|
||||
// Instantiate mission control with config from the sub server.
|
||||
//
|
||||
// TODO(joostjager): When we are further in the process of moving to sub
|
||||
@ -893,7 +866,7 @@ func newServer(cfg *Config, listenAddrs []net.Addr,
|
||||
paymentSessionSource := &routing.SessionSource{
|
||||
Graph: cachedGraph,
|
||||
MissionControl: s.missionControl,
|
||||
QueryBandwidth: queryBandwidth,
|
||||
GetLink: s.htlcSwitch.GetLinkByShortID,
|
||||
PathFindingConfig: pathFindingConfig,
|
||||
}
|
||||
|
||||
@ -915,7 +888,7 @@ func newServer(cfg *Config, listenAddrs []net.Addr,
|
||||
ChannelPruneExpiry: routing.DefaultChannelPruneExpiry,
|
||||
GraphPruneInterval: time.Hour,
|
||||
FirstTimePruneDelay: routing.DefaultFirstTimePruneDelay,
|
||||
QueryBandwidth: queryBandwidth,
|
||||
GetLink: s.htlcSwitch.GetLinkByShortID,
|
||||
AssumeChannelValid: cfg.Routing.AssumeChannelValid,
|
||||
NextPaymentID: sequencer.NextID,
|
||||
PathFindingConfig: pathFindingConfig,
|
||||
|
Reference in New Issue
Block a user