mirror of
https://github.com/lightningnetwork/lnd.git
synced 2025-03-03 17:26:57 +01:00
routing: add capacity to special edges
Having a capacity available is important for liquidity estimation. * We add a dummy capacity to hop hints. Hop hints specify neither the capacity nor a maxHTLC size, which is why we assume the channel to have a high capacity relative to the amount we send. * We add a capacity to local edges. These channels should always have a capacity associated with them, even in the neutrino case (a fallback to maxHTLC is not necessary). This is just for completeness, as the probability calculation for local channels is done separately.
This commit is contained in:
parent
b6d65752f7
commit
7df1482cfc
3 changed files with 25 additions and 5 deletions
|
@ -37,6 +37,11 @@ const (
|
||||||
// to avoid resizing and copies. It should be number on the same order as
|
// to avoid resizing and copies. It should be number on the same order as
|
||||||
// the number of active nodes in the network.
|
// the number of active nodes in the network.
|
||||||
estimatedNodeCount = 10000
|
estimatedNodeCount = 10000
|
||||||
|
|
||||||
|
// fakeHopHintCapacity is the capacity we assume for hop hint channels.
|
||||||
|
// This is a high number, which expresses that a hop hint channel should
|
||||||
|
// be able to route payments.
|
||||||
|
fakeHopHintCapacity = btcutil.Amount(10 * btcutil.SatoshiPerBitcoin)
|
||||||
)
|
)
|
||||||
|
|
||||||
// pathFinder defines the interface of a path finding algorithm.
|
// pathFinder defines the interface of a path finding algorithm.
|
||||||
|
@ -863,8 +868,17 @@ func findPath(g *graphParams, r *RestrictParams, cfg *PathFindingConfig,
|
||||||
return nil, 0, err
|
return nil, 0, err
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// We add hop hints that were supplied externally.
|
||||||
for _, reverseEdge := range additionalEdgesWithSrc[pivot] {
|
for _, reverseEdge := range additionalEdgesWithSrc[pivot] {
|
||||||
u.addPolicy(reverseEdge.sourceNode, reverseEdge.edge, 0)
|
// Hop hints don't contain a capacity. We set one here,
|
||||||
|
// since a capacity is needed for probability
|
||||||
|
// calculations. We set a high capacity to act as if
|
||||||
|
// there is enough liquidity, otherwise the hint would
|
||||||
|
// not have been added by a wallet.
|
||||||
|
u.addPolicy(
|
||||||
|
reverseEdge.sourceNode, reverseEdge.edge,
|
||||||
|
fakeHopHintCapacity,
|
||||||
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
amtToSend := partialPath.amountToReceive
|
amtToSend := partialPath.amountToReceive
|
||||||
|
|
|
@ -28,9 +28,12 @@ const (
|
||||||
// the timescale of about a week.
|
// the timescale of about a week.
|
||||||
DefaultBimodalDecayTime = 7 * 24 * time.Hour
|
DefaultBimodalDecayTime = 7 * 24 * time.Hour
|
||||||
|
|
||||||
// BimodalScaleMsatLimit is the maximum value for BimodalScaleMsat to
|
// BimodalScaleMsatMax is the maximum value for BimodalScaleMsat. We
|
||||||
// avoid numerical issues.
|
// limit it here to the fakeHopHintCapacity to avoid issues with hop
|
||||||
BimodalScaleMsatMax = lnwire.MilliSatoshi(21e17)
|
// hint probability calculations.
|
||||||
|
BimodalScaleMsatMax = lnwire.MilliSatoshi(
|
||||||
|
1000 * fakeHopHintCapacity / 4,
|
||||||
|
)
|
||||||
|
|
||||||
// BimodalEstimatorName is used to identify the bimodal estimator.
|
// BimodalEstimatorName is used to identify the bimodal estimator.
|
||||||
BimodalEstimatorName = "bimodal"
|
BimodalEstimatorName = "bimodal"
|
||||||
|
|
|
@ -218,7 +218,10 @@ func (u *edgeUnifier) getEdgeLocal(amt lnwire.MilliSatoshi,
|
||||||
maxBandwidth = bandwidth
|
maxBandwidth = bandwidth
|
||||||
|
|
||||||
// Update best edge.
|
// Update best edge.
|
||||||
bestEdge = &unifiedEdge{policy: edge.policy}
|
bestEdge = &unifiedEdge{
|
||||||
|
policy: edge.policy,
|
||||||
|
capacity: edge.capacity,
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return bestEdge
|
return bestEdge
|
||||||
|
|
Loading…
Add table
Reference in a new issue