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:
Joost Jager
2019-11-07 11:24:38 +01:00
parent 5a80c3459f
commit dc0399af51
4 changed files with 35 additions and 2 deletions

View File

@@ -118,6 +118,9 @@ type MissionControlConfig struct {
// probability completely and only base the probability on historical
// results, unless there are none available.
AprioriWeight float64
// SelfNode is our own pubkey.
SelfNode route.Vertex
}
// TimedPairResult describes a timestamped pair result.
@@ -261,6 +264,11 @@ func (m *MissionControl) GetProbability(fromNode, toNode route.Vertex,
now := m.now()
results := m.lastPairResult[fromNode]
// Use a distinct probability estimation function for local channels.
if fromNode == m.cfg.SelfNode {
return m.estimator.getLocalPairProbability(now, results, toNode)
}
return m.estimator.getPairProbability(now, results, toNode, amt)
}