mirror of
https://github.com/lightningnetwork/lnd.git
synced 2025-06-29 18:10:48 +02:00
routing: use distinct probability estimation for local channels
Previously we used the a priori probability also for our own untried channels. This led to local channels that had seen a success already being prioritized over untried local channels. In some cases, depending on the configured payment attempt cost, this could lead to the payment taking a two hop route while a direct payment was also possible.
This commit is contained in:
@ -123,6 +123,22 @@ func (p *probabilityEstimator) getPairProbability(
|
||||
)
|
||||
}
|
||||
|
||||
// getLocalPairProbability estimates the probability of successfully traversing
|
||||
// our own local channels to toNode.
|
||||
func (p *probabilityEstimator) getLocalPairProbability(
|
||||
now time.Time, results NodeResults, toNode route.Vertex) float64 {
|
||||
|
||||
// For local channels that have never been tried before, we assume them
|
||||
// to be successful. We have accurate balance and online status
|
||||
// information on our own channels, so when we select them in a route it
|
||||
// is close to certain that those channels will work.
|
||||
nodeProbability := p.prevSuccessProbability
|
||||
|
||||
return p.calculateProbability(
|
||||
now, results, nodeProbability, toNode, lnwire.MaxMilliSatoshi,
|
||||
)
|
||||
}
|
||||
|
||||
// calculateProbability estimates the probability of successfully traversing to
|
||||
// toNode based on historical payment outcomes and a fall-back node probability.
|
||||
func (p *probabilityEstimator) calculateProbability(
|
||||
|
Reference in New Issue
Block a user