2018-10-23 07:45:44 +03:00
|
|
|
// +build routerrpc
|
|
|
|
|
|
|
|
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-14 00:26:26 +03:00
|
|
|
RoutingConfig
|
|
|
|
|
2018-10-23 07:45:44 +03: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 16:19:35 +03:00
|
|
|
|
|
|
|
// RouterBackend contains shared logic between this sub server and the
|
|
|
|
// main rpc server.
|
|
|
|
RouterBackend *RouterBackend
|
2018-10-23 07:45:44 +03:00
|
|
|
}
|
2019-05-22 12:56:04 +03:00
|
|
|
|
|
|
|
// DefaultConfig defines the config defaults.
|
|
|
|
func DefaultConfig() *Config {
|
2019-07-14 00:26:26 +03:00
|
|
|
defaultRoutingConfig := RoutingConfig{
|
2019-05-22 12:56:04 +03:00
|
|
|
AprioriHopProbability: routing.DefaultAprioriHopProbability,
|
2019-09-04 18:40:14 +03:00
|
|
|
AprioriWeight: routing.DefaultAprioriWeight,
|
2019-05-22 12:56:04 +03:00
|
|
|
MinRouteProbability: routing.DefaultMinRouteProbability,
|
|
|
|
PenaltyHalfLife: routing.DefaultPenaltyHalfLife,
|
2019-07-14 00:26:26 +03:00
|
|
|
AttemptCost: routing.DefaultPaymentAttemptPenalty.
|
|
|
|
ToSatoshis(),
|
2019-06-26 14:00:35 +03:00
|
|
|
MaxMcHistory: routing.DefaultMaxMcHistory,
|
2019-07-14 00:26:26 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
return &Config{
|
|
|
|
RoutingConfig: defaultRoutingConfig,
|
2019-05-22 12:56:04 +03:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2019-06-18 19:30:56 +03:00
|
|
|
// GetRoutingConfig returns the routing config based on this sub server config.
|
|
|
|
func GetRoutingConfig(cfg *Config) *RoutingConfig {
|
|
|
|
return &RoutingConfig{
|
2019-05-22 12:56:04 +03:00
|
|
|
AprioriHopProbability: cfg.AprioriHopProbability,
|
2019-09-04 18:40:14 +03:00
|
|
|
AprioriWeight: cfg.AprioriWeight,
|
2019-05-22 12:56:04 +03:00
|
|
|
MinRouteProbability: cfg.MinRouteProbability,
|
2019-07-14 00:26:26 +03:00
|
|
|
AttemptCost: cfg.AttemptCost,
|
|
|
|
PenaltyHalfLife: cfg.PenaltyHalfLife,
|
2019-06-26 14:00:35 +03:00
|
|
|
MaxMcHistory: cfg.MaxMcHistory,
|
2019-05-22 12:56:04 +03:00
|
|
|
}
|
|
|
|
}
|