routerrpc: embed routing config
This commit is contained in:
parent
eb4e65e54f
commit
3dc83d1b6b
@ -3,26 +3,25 @@ package routerrpc
|
||||
import (
|
||||
"time"
|
||||
|
||||
"github.com/lightningnetwork/lnd/lnwire"
|
||||
"github.com/btcsuite/btcutil"
|
||||
)
|
||||
|
||||
// RoutingConfig contains the configurable parameters that control routing.
|
||||
type RoutingConfig struct {
|
||||
// PenaltyHalfLife defines after how much time a penalized node or
|
||||
// channel is back at 50% probability.
|
||||
PenaltyHalfLife time.Duration
|
||||
|
||||
// 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
|
||||
// MinRouteProbability 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
|
||||
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
|
||||
|
||||
import (
|
||||
"time"
|
||||
|
||||
"github.com/btcsuite/btcutil"
|
||||
"github.com/lightningnetwork/lnd/lnwire"
|
||||
"github.com/lightningnetwork/lnd/macaroons"
|
||||
"github.com/lightningnetwork/lnd/routing"
|
||||
)
|
||||
@ -17,28 +13,13 @@ import (
|
||||
// options, while if able to be populated, the latter fields MUST also be
|
||||
// specified.
|
||||
type Config struct {
|
||||
RoutingConfig
|
||||
|
||||
// RouterMacPath is the path for the router macaroon. If unspecified
|
||||
// then we assume that the macaroon will be found under the network
|
||||
// directory, named DefaultRouterMacFilename.
|
||||
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
|
||||
// server will find the macaroon named DefaultRouterMacFilename.
|
||||
NetworkDir string
|
||||
@ -62,13 +43,16 @@ type Config struct {
|
||||
|
||||
// DefaultConfig defines the config defaults.
|
||||
func DefaultConfig() *Config {
|
||||
return &Config{
|
||||
defaultRoutingConfig := RoutingConfig{
|
||||
AprioriHopProbability: routing.DefaultAprioriHopProbability,
|
||||
MinRouteProbability: routing.DefaultMinRouteProbability,
|
||||
PenaltyHalfLife: routing.DefaultPenaltyHalfLife,
|
||||
AttemptCost: int64(
|
||||
routing.DefaultPaymentAttemptPenalty.ToSatoshis(),
|
||||
),
|
||||
AttemptCost: routing.DefaultPaymentAttemptPenalty.
|
||||
ToSatoshis(),
|
||||
}
|
||||
|
||||
return &Config{
|
||||
RoutingConfig: defaultRoutingConfig,
|
||||
}
|
||||
}
|
||||
|
||||
@ -77,9 +61,7 @@ func GetRoutingConfig(cfg *Config) *RoutingConfig {
|
||||
return &RoutingConfig{
|
||||
AprioriHopProbability: cfg.AprioriHopProbability,
|
||||
MinRouteProbability: cfg.MinRouteProbability,
|
||||
PaymentAttemptPenalty: lnwire.NewMSatFromSatoshis(
|
||||
btcutil.Amount(cfg.AttemptCost),
|
||||
),
|
||||
PenaltyHalfLife: cfg.PenaltyHalfLife,
|
||||
AttemptCost: cfg.AttemptCost,
|
||||
PenaltyHalfLife: cfg.PenaltyHalfLife,
|
||||
}
|
||||
}
|
||||
|
@ -19,7 +19,8 @@ func GetRoutingConfig(cfg *Config) *RoutingConfig {
|
||||
return &RoutingConfig{
|
||||
AprioriHopProbability: routing.DefaultAprioriHopProbability,
|
||||
MinRouteProbability: routing.DefaultMinRouteProbability,
|
||||
PaymentAttemptPenalty: routing.DefaultPaymentAttemptPenalty,
|
||||
PenaltyHalfLife: routing.DefaultPenaltyHalfLife,
|
||||
AttemptCost: routing.DefaultPaymentAttemptPenalty.
|
||||
ToSatoshis(),
|
||||
PenaltyHalfLife: routing.DefaultPenaltyHalfLife,
|
||||
}
|
||||
}
|
||||
|
@ -662,12 +662,14 @@ func newServer(listenAddrs []net.Addr, chanDB *channeldb.DB,
|
||||
|
||||
srvrLog.Debugf("Instantiating payment session source with config: "+
|
||||
"PaymentAttemptPenalty=%v, MinRouteProbability=%v",
|
||||
int64(routingConfig.PaymentAttemptPenalty.ToSatoshis()),
|
||||
int64(routingConfig.AttemptCost),
|
||||
routingConfig.MinRouteProbability)
|
||||
|
||||
pathFindingConfig := routing.PathFindingConfig{
|
||||
PaymentAttemptPenalty: routingConfig.PaymentAttemptPenalty,
|
||||
MinProbability: routingConfig.MinRouteProbability,
|
||||
PaymentAttemptPenalty: lnwire.NewMSatFromSatoshis(
|
||||
routingConfig.AttemptCost,
|
||||
),
|
||||
MinProbability: routingConfig.MinRouteProbability,
|
||||
}
|
||||
|
||||
paymentSessionSource := &routing.SessionSource{
|
||||
|
Loading…
Reference in New Issue
Block a user