routing: weight findPath more heavily towards fees during edge relaxation

In this commit, we modify the edgeWeight function that’s used within
the findPath method to weight fees more heavily than the time lock
value at an edge. We do this in order to greedily prefer lower fees
during path finding. This is a simple stop gap in place of more complex
weighting parameters that will be investigated later.

We also modify the edge distance to use an int64 rather than a float.
Finally an additional test has been added in order to excessive this
new change. Before the commit, the test was failing as we preferred the
route with lower total time lock.
This commit is contained in:
Olaoluwa Osuntokun
2018-02-12 16:27:30 -08:00
parent ad0f5b31f6
commit 528aa67df7
5 changed files with 87 additions and 12 deletions

View File

@ -390,7 +390,9 @@ func TestBasicGraphPathFinding(t *testing.T) {
// Additionally, we'll ensure that the amount to forward, and fees
// computed for each hop are correct.
firstHopFee := computeFee(paymentAmt, route.Hops[1].Channel)
firstHopFee := computeFee(
paymentAmt, route.Hops[1].Channel.ChannelEdgePolicy,
)
if route.Hops[0].Fee != firstHopFee {
t.Fatalf("first hop fee incorrect: expected %v, got %v",
firstHopFee, route.Hops[0].Fee)
@ -507,7 +509,9 @@ func TestKShortestPathFinding(t *testing.T) {
paymentAmt := lnwire.NewMSatFromSatoshis(100)
target := aliases["luoji"]
paths, err := findPaths(nil, graph, sourceNode, target, paymentAmt)
paths, err := findPaths(
nil, graph, sourceNode, target, paymentAmt, 100,
)
if err != nil {
t.Fatalf("unable to find paths between roasbeef and "+
"luo ji: %v", err)