lnrpc+routing: add edges and nodes restrictions to query routes

This commit allows the execution of QueryRoutes to be controlled using
lists of black-listed edges and nodes. Any path returned will not pass
through the edges and/or nodes on the list.
This commit is contained in:
Joost Jager
2019-03-05 12:42:29 +01:00
parent 4376f3e1bd
commit b09adc3219
8 changed files with 757 additions and 595 deletions

View File

@@ -47,6 +47,12 @@ const (
noFeeLimit = lnwire.MilliSatoshi(math.MaxUint32)
)
var (
noRestrictions = &RestrictParams{
FeeLimit: noFeeLimit,
}
)
var (
testSig = &btcec.Signature{
R: new(big.Int),
@@ -953,9 +959,12 @@ func TestKShortestPathFinding(t *testing.T) {
paymentAmt := lnwire.NewMSatFromSatoshis(100)
target := graph.aliasMap["luoji"]
restrictions := &RestrictParams{
FeeLimit: noFeeLimit,
}
paths, err := findPaths(
nil, graph.graph, sourceNode, target, paymentAmt, noFeeLimit, 100,
nil,
nil, graph.graph, sourceNode, target, paymentAmt, restrictions,
100, nil,
)
if err != nil {
t.Fatalf("unable to find paths between roasbeef and "+
@@ -1706,7 +1715,7 @@ func TestPathFindSpecExample(t *testing.T) {
// Query for a route of 4,999,999 mSAT to carol.
carol := ctx.aliases["C"]
const amt lnwire.MilliSatoshi = 4999999
routes, err := ctx.router.FindRoutes(carol, amt, noFeeLimit, 100)
routes, err := ctx.router.FindRoutes(carol, amt, noRestrictions, 100)
if err != nil {
t.Fatalf("unable to find route: %v", err)
}
@@ -1767,7 +1776,7 @@ func TestPathFindSpecExample(t *testing.T) {
// We'll now request a route from A -> B -> C.
ctx.router.routeCache = make(map[routeTuple][]*Route)
routes, err = ctx.router.FindRoutes(carol, amt, noFeeLimit, 100)
routes, err = ctx.router.FindRoutes(carol, amt, noRestrictions, 100)
if err != nil {
t.Fatalf("unable to find routes: %v", err)
}