2018-10-22 21:45:44 -07:00
|
|
|
package routerrpc
|
|
|
|
|
|
|
|
import (
|
|
|
|
"github.com/lightningnetwork/lnd/macaroons"
|
|
|
|
"github.com/lightningnetwork/lnd/routing"
|
|
|
|
)
|
|
|
|
|
|
|
|
// Config is the main configuration file for the router RPC server. It contains
|
|
|
|
// all the items required for the router RPC server to carry out its duties.
|
|
|
|
// The fields with struct tags are meant to be parsed as normal configuration
|
|
|
|
// options, while if able to be populated, the latter fields MUST also be
|
|
|
|
// specified.
|
|
|
|
type Config struct {
|
2019-07-13 23:26:26 +02:00
|
|
|
RoutingConfig
|
|
|
|
|
2018-10-22 21:45:44 -07:00
|
|
|
// 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"`
|
|
|
|
|
|
|
|
// NetworkDir is the main network directory wherein the router rpc
|
|
|
|
// server will find the macaroon named DefaultRouterMacFilename.
|
|
|
|
NetworkDir string
|
|
|
|
|
|
|
|
// MacService is the main macaroon service that we'll use to handle
|
|
|
|
// authentication for the Router rpc server.
|
|
|
|
MacService *macaroons.Service
|
|
|
|
|
|
|
|
// Router is the main channel router instance that backs this RPC
|
|
|
|
// server.
|
|
|
|
//
|
|
|
|
// TODO(roasbeef): make into pkg lvl interface?
|
|
|
|
//
|
|
|
|
// TODO(roasbeef): assumes router handles saving payment state
|
|
|
|
Router *routing.ChannelRouter
|
2019-03-14 14:19:35 +01:00
|
|
|
|
|
|
|
// RouterBackend contains shared logic between this sub server and the
|
|
|
|
// main rpc server.
|
|
|
|
RouterBackend *RouterBackend
|
2018-10-22 21:45:44 -07:00
|
|
|
}
|
2019-05-22 11:56:04 +02:00
|
|
|
|
|
|
|
// DefaultConfig defines the config defaults.
|
|
|
|
func DefaultConfig() *Config {
|
2019-07-13 23:26:26 +02:00
|
|
|
defaultRoutingConfig := RoutingConfig{
|
2023-02-06 14:29:02 +01:00
|
|
|
ProbabilityEstimatorType: routing.DefaultEstimator,
|
|
|
|
MinRouteProbability: routing.DefaultMinRouteProbability,
|
|
|
|
|
|
|
|
AttemptCost: routing.DefaultAttemptCost.ToSatoshis(),
|
|
|
|
AttemptCostPPM: routing.DefaultAttemptCostPPM,
|
|
|
|
MaxMcHistory: routing.DefaultMaxMcHistory,
|
|
|
|
McFlushInterval: routing.DefaultMcFlushInterval,
|
|
|
|
AprioriConfig: &AprioriConfig{
|
2023-02-24 11:59:44 +01:00
|
|
|
HopProbability: routing.DefaultAprioriHopProbability,
|
|
|
|
Weight: routing.DefaultAprioriWeight,
|
|
|
|
PenaltyHalfLife: routing.DefaultPenaltyHalfLife,
|
|
|
|
CapacityFraction: routing.DefaultCapacityFraction,
|
2023-02-06 14:29:02 +01:00
|
|
|
},
|
|
|
|
BimodalConfig: &BimodalConfig{
|
|
|
|
Scale: int64(routing.DefaultBimodalScaleMsat),
|
|
|
|
NodeWeight: routing.DefaultBimodalNodeWeight,
|
|
|
|
DecayTime: routing.DefaultBimodalDecayTime,
|
|
|
|
},
|
2019-07-13 23:26:26 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
return &Config{
|
|
|
|
RoutingConfig: defaultRoutingConfig,
|
2019-05-22 11:56:04 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2019-06-18 18:30:56 +02:00
|
|
|
// GetRoutingConfig returns the routing config based on this sub server config.
|
|
|
|
func GetRoutingConfig(cfg *Config) *RoutingConfig {
|
|
|
|
return &RoutingConfig{
|
2023-02-06 14:29:02 +01:00
|
|
|
ProbabilityEstimatorType: cfg.ProbabilityEstimatorType,
|
|
|
|
MinRouteProbability: cfg.MinRouteProbability,
|
|
|
|
AttemptCost: cfg.AttemptCost,
|
|
|
|
AttemptCostPPM: cfg.AttemptCostPPM,
|
|
|
|
MaxMcHistory: cfg.MaxMcHistory,
|
|
|
|
McFlushInterval: cfg.McFlushInterval,
|
|
|
|
AprioriConfig: &AprioriConfig{
|
2023-02-24 11:59:44 +01:00
|
|
|
HopProbability: cfg.AprioriConfig.HopProbability,
|
|
|
|
Weight: cfg.AprioriConfig.Weight,
|
|
|
|
PenaltyHalfLife: cfg.AprioriConfig.PenaltyHalfLife,
|
|
|
|
CapacityFraction: cfg.AprioriConfig.CapacityFraction,
|
2023-02-06 14:29:02 +01:00
|
|
|
},
|
|
|
|
BimodalConfig: &BimodalConfig{
|
|
|
|
Scale: cfg.BimodalConfig.Scale,
|
|
|
|
NodeWeight: cfg.BimodalConfig.NodeWeight,
|
|
|
|
DecayTime: cfg.BimodalConfig.DecayTime,
|
|
|
|
},
|
2019-05-22 11:56:04 +02:00
|
|
|
}
|
|
|
|
}
|