routing: add error var for pre-built route tried

This commit is contained in:
Joost Jager 2019-11-21 12:05:43 +01:00
parent ac2df9bbf4
commit b5f1bde604
No known key found for this signature in database
GPG Key ID: A61B9D4C393C59C7

@ -1,7 +1,7 @@
package routing package routing
import ( import (
"fmt" "errors"
"github.com/lightningnetwork/lnd/channeldb" "github.com/lightningnetwork/lnd/channeldb"
"github.com/lightningnetwork/lnd/lnwire" "github.com/lightningnetwork/lnd/lnwire"
@ -12,6 +12,12 @@ import (
// to prevent an HTLC being failed if some blocks are mined while it's in-flight. // to prevent an HTLC being failed if some blocks are mined while it's in-flight.
const BlockPadding uint16 = 3 const BlockPadding uint16 = 3
var (
// errPrebuiltRouteTried is returned when the single pre-built route
// failed and there is nothing more we can do.
errPrebuiltRouteTried = errors.New("pre-built route already tried")
)
// PaymentSession is used during SendPayment attempts to provide routes to // PaymentSession is used during SendPayment attempts to provide routes to
// attempt. It also defines methods to give the PaymentSession additional // attempt. It also defines methods to give the PaymentSession additional
// information learned during the previous attempts. // information learned during the previous attempts.
@ -66,7 +72,7 @@ func (p *paymentSession) RequestRoute(payment *LightningPayment,
// If the pre-built route has been tried already, the payment session is // If the pre-built route has been tried already, the payment session is
// over. // over.
case p.preBuiltRoute != nil: case p.preBuiltRoute != nil:
return nil, fmt.Errorf("pre-built route already tried") return nil, errPrebuiltRouteTried
} }
// Add BlockPadding to the finalCltvDelta so that the receiving node // Add BlockPadding to the finalCltvDelta so that the receiving node