routing+routerrpc: rename PaymentAttemptPenalty to AttemptCost

Make field names consistent with the command line flag.
This commit is contained in:
Joost Jager
2020-09-08 13:07:35 +02:00
parent 751b02361e
commit 17a6175e8b
7 changed files with 23 additions and 26 deletions

View File

@@ -46,9 +46,8 @@ func DefaultConfig() *Config {
AprioriWeight: routing.DefaultAprioriWeight, AprioriWeight: routing.DefaultAprioriWeight,
MinRouteProbability: routing.DefaultMinRouteProbability, MinRouteProbability: routing.DefaultMinRouteProbability,
PenaltyHalfLife: routing.DefaultPenaltyHalfLife, PenaltyHalfLife: routing.DefaultPenaltyHalfLife,
AttemptCost: routing.DefaultPaymentAttemptPenalty. AttemptCost: routing.DefaultAttemptCost.ToSatoshis(),
ToSatoshis(), MaxMcHistory: routing.DefaultMaxMcHistory,
MaxMcHistory: routing.DefaultMaxMcHistory,
} }
return &Config{ return &Config{

View File

@@ -29,9 +29,9 @@ type RoutingConfig struct {
// channel is back at 50% probability. // channel is back at 50% probability.
PenaltyHalfLife time.Duration `long:"penaltyhalflife" description:"Defines the duration after which a penalized node or channel is back at 50% probability"` PenaltyHalfLife time.Duration `long:"penaltyhalflife" description:"Defines the duration after which a penalized node or channel is back at 50% probability"`
// AttemptCost is the virtual cost in path finding weight units of // AttemptCost is the fixed virtual cost in path finding of a failed
// executing a payment attempt that fails. It is used to trade off // payment attempt. It is used to trade off potentially better routes
// potentially better routes against their probability of succeeding. // against their probability of succeeding.
AttemptCost btcutil.Amount `long:"attemptcost" description:"The (virtual) cost in sats of a failed payment attempt"` AttemptCost btcutil.Amount `long:"attemptcost" description:"The (virtual) cost in sats of a failed payment attempt"`
// MaxMcHistory defines the maximum number of payment results that // MaxMcHistory defines the maximum number of payment results that

View File

@@ -65,8 +65,8 @@ func newIntegratedRoutingContext(t *testing.T) *integratedRoutingContext {
}, },
pathFindingCfg: PathFindingConfig{ pathFindingCfg: PathFindingConfig{
PaymentAttemptPenalty: 1000, AttemptCost: 1000,
MinProbability: 0.01, MinProbability: 0.01,
}, },
source: source, source: source,

View File

@@ -45,11 +45,10 @@ type pathFinder = func(g *graphParams, r *RestrictParams,
[]*channeldb.ChannelEdgePolicy, error) []*channeldb.ChannelEdgePolicy, error)
var ( var (
// DefaultPaymentAttemptPenalty is the virtual cost in path finding weight // DefaultAttemptCost is the default virtual cost in path finding of a
// units of executing a payment attempt that fails. It is used to trade // failed payment attempt. It is used to trade off potentially better
// off potentially better routes against their probability of // routes against their probability of succeeding.
// succeeding. DefaultAttemptCost = lnwire.NewMSatFromSatoshis(100)
DefaultPaymentAttemptPenalty = lnwire.NewMSatFromSatoshis(100)
// DefaultMinRouteProbability is the default minimum probability for routes // DefaultMinRouteProbability is the default minimum probability for routes
// returned from findPath. // returned from findPath.
@@ -315,11 +314,10 @@ type RestrictParams struct {
// PathFindingConfig defines global parameters that control the trade-off in // PathFindingConfig defines global parameters that control the trade-off in
// path finding between fees and probabiity. // path finding between fees and probabiity.
type PathFindingConfig struct { type PathFindingConfig struct {
// PaymentAttemptPenalty is the virtual cost in path finding weight // AttemptCost is the virtual cost in path finding of a failed
// units of executing a payment attempt that fails. It is used to trade // payment attempt. It is used to trade off potentially better routes
// off potentially better routes against their probability of // against their probability of succeeding.
// succeeding. AttemptCost lnwire.MilliSatoshi
PaymentAttemptPenalty lnwire.MilliSatoshi
// MinProbability defines the minimum success probability of the // MinProbability defines the minimum success probability of the
// returned route. // returned route.
@@ -644,7 +642,7 @@ func findPath(g *graphParams, r *RestrictParams, cfg *PathFindingConfig,
// probability. // probability.
tempDist := getProbabilityBasedDist( tempDist := getProbabilityBasedDist(
tempWeight, probability, tempWeight, probability,
int64(cfg.PaymentAttemptPenalty), int64(cfg.AttemptCost),
) )
// If there is already a best route stored, compare this // If there is already a best route stored, compare this

View File

@@ -2582,8 +2582,8 @@ func testProbabilityRouting(t *testing.T, p10, p11, p20, minProbability float64,
} }
ctx.pathFindingConfig = PathFindingConfig{ ctx.pathFindingConfig = PathFindingConfig{
PaymentAttemptPenalty: lnwire.NewMSatFromSatoshis(10), AttemptCost: lnwire.NewMSatFromSatoshis(10),
MinProbability: minProbability, MinProbability: minProbability,
} }
path, err := ctx.findPath(target, paymentAmt) path, err := ctx.findPath(target, paymentAmt)
@@ -2656,7 +2656,7 @@ func TestEqualCostRouteSelection(t *testing.T) {
} }
ctx.pathFindingConfig = PathFindingConfig{ ctx.pathFindingConfig = PathFindingConfig{
PaymentAttemptPenalty: lnwire.NewMSatFromSatoshis(1), AttemptCost: lnwire.NewMSatFromSatoshis(1),
} }
path, err := ctx.findPath(target, paymentAmt) path, err := ctx.findPath(target, paymentAmt)

View File

@@ -79,8 +79,8 @@ func createTestCtxFromGraphInstance(startingHeight uint32, graphInstance *testGr
chainView := newMockChainView(chain) chainView := newMockChainView(chain)
pathFindingConfig := PathFindingConfig{ pathFindingConfig := PathFindingConfig{
MinProbability: 0.01, MinProbability: 0.01,
PaymentAttemptPenalty: 100, AttemptCost: 100,
} }
mcConfig := &MissionControlConfig{ mcConfig := &MissionControlConfig{

View File

@@ -724,12 +724,12 @@ func newServer(cfg *Config, listenAddrs []net.Addr,
} }
srvrLog.Debugf("Instantiating payment session source with config: "+ srvrLog.Debugf("Instantiating payment session source with config: "+
"PaymentAttemptPenalty=%v, MinRouteProbability=%v", "AttemptCost=%v, MinRouteProbability=%v",
int64(routingConfig.AttemptCost), int64(routingConfig.AttemptCost),
routingConfig.MinRouteProbability) routingConfig.MinRouteProbability)
pathFindingConfig := routing.PathFindingConfig{ pathFindingConfig := routing.PathFindingConfig{
PaymentAttemptPenalty: lnwire.NewMSatFromSatoshis( AttemptCost: lnwire.NewMSatFromSatoshis(
routingConfig.AttemptCost, routingConfig.AttemptCost,
), ),
MinProbability: routingConfig.MinRouteProbability, MinProbability: routingConfig.MinRouteProbability,