routing+routerrpc: expose mission control parameters in lnd config
This commit exposes the three main parameters that influence mission control and path finding to the user as command line or config file flags. It allows for fine-tuning for optimal results.
This commit is contained in:
10 files changed
+145
-32
No files matched your search
@@ -3,7 +3,12 @@
|
||||
package routerrpc
|
||||
|
||||
import (
|
||||
"time"
|
||||
|
||||
"github.com/lightningnetwork/lnd/lnwire"
|
||||
|
||||
"github.com/btcsuite/btcd/chaincfg"
|
||||
"github.com/btcsuite/btcutil"
|
||||
"github.com/lightningnetwork/lnd/macaroons"
|
||||
"github.com/lightningnetwork/lnd/routing"
|
||||
)
|
||||
@@ -19,6 +24,23 @@ type Config struct {
|
||||
// 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
|
||||
@@ -45,3 +67,28 @@ type Config struct {
|
||||
// main rpc server.
|
||||
RouterBackend *RouterBackend
|
||||
}
|
||||
|
||||
// DefaultConfig defines the config defaults.
|
||||
func DefaultConfig() *Config {
|
||||
return &Config{
|
||||
AprioriHopProbability: routing.DefaultAprioriHopProbability,
|
||||
MinRouteProbability: routing.DefaultMinRouteProbability,
|
||||
PenaltyHalfLife: routing.DefaultPenaltyHalfLife,
|
||||
AttemptCost: int64(
|
||||
routing.DefaultPaymentAttemptPenalty.ToSatoshis(),
|
||||
),
|
||||
}
|
||||
}
|
||||
|
||||
// GetMissionControlConfig returns the mission control config based on this sub
|
||||
// server config.
|
||||
func GetMissionControlConfig(cfg *Config) *routing.MissionControlConfig {
|
||||
return &routing.MissionControlConfig{
|
||||
AprioriHopProbability: cfg.AprioriHopProbability,
|
||||
MinRouteProbability: cfg.MinRouteProbability,
|
||||
PaymentAttemptPenalty: lnwire.NewMSatFromSatoshis(
|
||||
btcutil.Amount(cfg.AttemptCost),
|
||||
),
|
||||
PenaltyHalfLife: cfg.PenaltyHalfLife,
|
||||
}
|
||||
}
|
||||
@@ -2,6 +2,25 @@
|
||||
|
||||
package routerrpc
|
||||
|
||||
// Config is the default config for the package. When the build tag isn't
|
||||
import "github.com/lightningnetwork/lnd/routing"
|
||||
|
||||
// Config is the default config struct for the package. When the build tag isn't
|
||||
// specified, then we output a blank config.
|
||||
type Config struct{}
|
||||
|
||||
// DefaultConfig defines the config defaults. Without the sub server enabled,
|
||||
// there are no defaults to set.
|
||||
func DefaultConfig() *Config {
|
||||
return &Config{}
|
||||
}
|
||||
|
||||
// GetMissionControlConfig returns the mission control config based on this sub
|
||||
// server config.
|
||||
func GetMissionControlConfig(cfg *Config) *routing.MissionControlConfig {
|
||||
return &routing.MissionControlConfig{
|
||||
AprioriHopProbability: routing.DefaultAprioriHopProbability,
|
||||
MinRouteProbability: routing.DefaultMinRouteProbability,
|
||||
PaymentAttemptPenalty: routing.DefaultPaymentAttemptPenalty,
|
||||
PenaltyHalfLife: routing.DefaultPenaltyHalfLife,
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user