routerrpc: embed routing config
This commit is contained in:
parent
eb4e65e54f
commit
3dc83d1b6b
@ -3,26 +3,25 @@ package routerrpc
|
|||||||
import (
|
import (
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
"github.com/lightningnetwork/lnd/lnwire"
|
"github.com/btcsuite/btcutil"
|
||||||
)
|
)
|
||||||
|
|
||||||
// RoutingConfig contains the configurable parameters that control routing.
|
// RoutingConfig contains the configurable parameters that control routing.
|
||||||
type RoutingConfig struct {
|
type RoutingConfig struct {
|
||||||
// PenaltyHalfLife defines after how much time a penalized node or
|
// MinRouteProbability is the minimum required route success probability
|
||||||
// channel is back at 50% probability.
|
// to attempt the payment.
|
||||||
PenaltyHalfLife time.Duration
|
MinRouteProbability float64 `long:"minrtprob" description:"Minimum required route success probability to attempt the payment"`
|
||||||
|
|
||||||
// PaymentAttemptPenalty is the virtual cost in path finding weight
|
|
||||||
// units of executing a payment attempt that fails. It is used to trade
|
|
||||||
// off potentially better routes against their probability of
|
|
||||||
// succeeding.
|
|
||||||
PaymentAttemptPenalty lnwire.MilliSatoshi
|
|
||||||
|
|
||||||
// MinProbability defines the minimum success probability of the
|
|
||||||
// returned route.
|
|
||||||
MinRouteProbability float64
|
|
||||||
|
|
||||||
// AprioriHopProbability is the assumed success probability of a hop in
|
// AprioriHopProbability is the assumed success probability of a hop in
|
||||||
// a route when no other information is available.
|
// a route when no other information is available.
|
||||||
AprioriHopProbability float64
|
AprioriHopProbability float64 `long:"apriorihopprob" description:"Assumed success probability of a hop in a route when no other information is available."`
|
||||||
|
|
||||||
|
// PenaltyHalfLife defines after how much time 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
|
||||||
|
// executing a payment attempt that fails. It is used to trade off
|
||||||
|
// potentially better routes against their probability of succeeding.
|
||||||
|
AttemptCost btcutil.Amount `long:"attemptcost" description:"The (virtual) cost in sats of a failed payment attempt"`
|
||||||
}
|
}
|
||||||
|
@ -3,10 +3,6 @@
|
|||||||
package routerrpc
|
package routerrpc
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"time"
|
|
||||||
|
|
||||||
"github.com/btcsuite/btcutil"
|
|
||||||
"github.com/lightningnetwork/lnd/lnwire"
|
|
||||||
"github.com/lightningnetwork/lnd/macaroons"
|
"github.com/lightningnetwork/lnd/macaroons"
|
||||||
"github.com/lightningnetwork/lnd/routing"
|
"github.com/lightningnetwork/lnd/routing"
|
||||||
)
|
)
|
||||||
@ -17,28 +13,13 @@ import (
|
|||||||
// options, while if able to be populated, the latter fields MUST also be
|
// options, while if able to be populated, the latter fields MUST also be
|
||||||
// specified.
|
// specified.
|
||||||
type Config struct {
|
type Config struct {
|
||||||
|
RoutingConfig
|
||||||
|
|
||||||
// RouterMacPath is the path for the router macaroon. If unspecified
|
// RouterMacPath is the path for the router macaroon. If unspecified
|
||||||
// then we assume that the macaroon will be found under the network
|
// then we assume that the macaroon will be found under the network
|
||||||
// directory, named DefaultRouterMacFilename.
|
// directory, named DefaultRouterMacFilename.
|
||||||
RouterMacPath string `long:"routermacaroonpath" description:"Path to the router macaroon"`
|
RouterMacPath string `long:"routermacaroonpath" description:"Path to the router macaroon"`
|
||||||
|
|
||||||
// MinProbability is the minimum required route success probability to
|
|
||||||
// attempt the payment.
|
|
||||||
MinRouteProbability float64 `long:"minrtprob" description:"Minimum required route success probability to attempt the payment"`
|
|
||||||
|
|
||||||
// AprioriHopProbability is the assumed success probability of a hop in
|
|
||||||
// a route when no other information is available.
|
|
||||||
AprioriHopProbability float64 `long:"apriorihopprob" description:"Assumed success probability of a hop in a route when no other information is available."`
|
|
||||||
|
|
||||||
// PenaltyHalfLife defines after how much time 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
|
|
||||||
// executing a payment attempt that fails. It is used to trade off
|
|
||||||
// potentially better routes against their probability of succeeding.
|
|
||||||
AttemptCost int64 `long:"attemptcost" description:"The (virtual) cost in sats of a failed payment attempt"`
|
|
||||||
|
|
||||||
// NetworkDir is the main network directory wherein the router rpc
|
// NetworkDir is the main network directory wherein the router rpc
|
||||||
// server will find the macaroon named DefaultRouterMacFilename.
|
// server will find the macaroon named DefaultRouterMacFilename.
|
||||||
NetworkDir string
|
NetworkDir string
|
||||||
@ -62,13 +43,16 @@ type Config struct {
|
|||||||
|
|
||||||
// DefaultConfig defines the config defaults.
|
// DefaultConfig defines the config defaults.
|
||||||
func DefaultConfig() *Config {
|
func DefaultConfig() *Config {
|
||||||
return &Config{
|
defaultRoutingConfig := RoutingConfig{
|
||||||
AprioriHopProbability: routing.DefaultAprioriHopProbability,
|
AprioriHopProbability: routing.DefaultAprioriHopProbability,
|
||||||
MinRouteProbability: routing.DefaultMinRouteProbability,
|
MinRouteProbability: routing.DefaultMinRouteProbability,
|
||||||
PenaltyHalfLife: routing.DefaultPenaltyHalfLife,
|
PenaltyHalfLife: routing.DefaultPenaltyHalfLife,
|
||||||
AttemptCost: int64(
|
AttemptCost: routing.DefaultPaymentAttemptPenalty.
|
||||||
routing.DefaultPaymentAttemptPenalty.ToSatoshis(),
|
ToSatoshis(),
|
||||||
),
|
}
|
||||||
|
|
||||||
|
return &Config{
|
||||||
|
RoutingConfig: defaultRoutingConfig,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -77,9 +61,7 @@ func GetRoutingConfig(cfg *Config) *RoutingConfig {
|
|||||||
return &RoutingConfig{
|
return &RoutingConfig{
|
||||||
AprioriHopProbability: cfg.AprioriHopProbability,
|
AprioriHopProbability: cfg.AprioriHopProbability,
|
||||||
MinRouteProbability: cfg.MinRouteProbability,
|
MinRouteProbability: cfg.MinRouteProbability,
|
||||||
PaymentAttemptPenalty: lnwire.NewMSatFromSatoshis(
|
AttemptCost: cfg.AttemptCost,
|
||||||
btcutil.Amount(cfg.AttemptCost),
|
PenaltyHalfLife: cfg.PenaltyHalfLife,
|
||||||
),
|
|
||||||
PenaltyHalfLife: cfg.PenaltyHalfLife,
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -19,7 +19,8 @@ func GetRoutingConfig(cfg *Config) *RoutingConfig {
|
|||||||
return &RoutingConfig{
|
return &RoutingConfig{
|
||||||
AprioriHopProbability: routing.DefaultAprioriHopProbability,
|
AprioriHopProbability: routing.DefaultAprioriHopProbability,
|
||||||
MinRouteProbability: routing.DefaultMinRouteProbability,
|
MinRouteProbability: routing.DefaultMinRouteProbability,
|
||||||
PaymentAttemptPenalty: routing.DefaultPaymentAttemptPenalty,
|
AttemptCost: routing.DefaultPaymentAttemptPenalty.
|
||||||
PenaltyHalfLife: routing.DefaultPenaltyHalfLife,
|
ToSatoshis(),
|
||||||
|
PenaltyHalfLife: routing.DefaultPenaltyHalfLife,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -662,12 +662,14 @@ func newServer(listenAddrs []net.Addr, chanDB *channeldb.DB,
|
|||||||
|
|
||||||
srvrLog.Debugf("Instantiating payment session source with config: "+
|
srvrLog.Debugf("Instantiating payment session source with config: "+
|
||||||
"PaymentAttemptPenalty=%v, MinRouteProbability=%v",
|
"PaymentAttemptPenalty=%v, MinRouteProbability=%v",
|
||||||
int64(routingConfig.PaymentAttemptPenalty.ToSatoshis()),
|
int64(routingConfig.AttemptCost),
|
||||||
routingConfig.MinRouteProbability)
|
routingConfig.MinRouteProbability)
|
||||||
|
|
||||||
pathFindingConfig := routing.PathFindingConfig{
|
pathFindingConfig := routing.PathFindingConfig{
|
||||||
PaymentAttemptPenalty: routingConfig.PaymentAttemptPenalty,
|
PaymentAttemptPenalty: lnwire.NewMSatFromSatoshis(
|
||||||
MinProbability: routingConfig.MinRouteProbability,
|
routingConfig.AttemptCost,
|
||||||
|
),
|
||||||
|
MinProbability: routingConfig.MinRouteProbability,
|
||||||
}
|
}
|
||||||
|
|
||||||
paymentSessionSource := &routing.SessionSource{
|
paymentSessionSource := &routing.SessionSource{
|
||||||
|
Loading…
Reference in New Issue
Block a user