github.com/decred/dcrlnd@v0.7.6/lnrpc/routerrpc/config.go (about)

     1  package routerrpc
     2  
     3  import (
     4  	"github.com/decred/dcrlnd/macaroons"
     5  	"github.com/decred/dcrlnd/routing"
     6  )
     7  
     8  // Config is the main configuration file for the router RPC server. It contains
     9  // all the items required for the router RPC server to carry out its duties.
    10  // The fields with struct tags are meant to be parsed as normal configuration
    11  // options, while if able to be populated, the latter fields MUST also be
    12  // specified.
    13  type Config struct {
    14  	RoutingConfig
    15  
    16  	// RouterMacPath is the path for the router macaroon. If unspecified
    17  	// then we assume that the macaroon will be found under the network
    18  	// directory, named DefaultRouterMacFilename.
    19  	RouterMacPath string `long:"routermacaroonpath" description:"Path to the router macaroon"`
    20  
    21  	// NetworkDir is the main network directory wherein the router rpc
    22  	// server will find the macaroon named DefaultRouterMacFilename.
    23  	NetworkDir string
    24  
    25  	// MacService is the main macaroon service that we'll use to handle
    26  	// authentication for the Router rpc server.
    27  	MacService *macaroons.Service
    28  
    29  	// Router is the main channel router instance that backs this RPC
    30  	// server.
    31  	//
    32  	// TODO(roasbeef): make into pkg lvl interface?
    33  	//
    34  	// TODO(roasbeef): assumes router handles saving payment state
    35  	Router *routing.ChannelRouter
    36  
    37  	// RouterBackend contains shared logic between this sub server and the
    38  	// main rpc server.
    39  	RouterBackend *RouterBackend
    40  }
    41  
    42  // DefaultConfig defines the config defaults.
    43  func DefaultConfig() *Config {
    44  	defaultRoutingConfig := RoutingConfig{
    45  		AprioriHopProbability: routing.DefaultAprioriHopProbability,
    46  		AprioriWeight:         routing.DefaultAprioriWeight,
    47  		MinRouteProbability:   routing.DefaultMinRouteProbability,
    48  		PenaltyHalfLife:       routing.DefaultPenaltyHalfLife,
    49  		AttemptCost:           routing.DefaultAttemptCost.ToAtoms(),
    50  		AttemptCostPPM:        routing.DefaultAttemptCostPPM,
    51  		MaxMcHistory:          routing.DefaultMaxMcHistory,
    52  		McFlushInterval:       routing.DefaultMcFlushInterval,
    53  	}
    54  
    55  	return &Config{
    56  		RoutingConfig: defaultRoutingConfig,
    57  	}
    58  }
    59  
    60  // GetRoutingConfig returns the routing config based on this sub server config.
    61  func GetRoutingConfig(cfg *Config) *RoutingConfig {
    62  	return &RoutingConfig{
    63  		AprioriHopProbability: cfg.AprioriHopProbability,
    64  		AprioriWeight:         cfg.AprioriWeight,
    65  		MinRouteProbability:   cfg.MinRouteProbability,
    66  		AttemptCost:           cfg.AttemptCost,
    67  		AttemptCostPPM:        cfg.AttemptCostPPM,
    68  		PenaltyHalfLife:       cfg.PenaltyHalfLife,
    69  		MaxMcHistory:          cfg.MaxMcHistory,
    70  		McFlushInterval:       cfg.McFlushInterval,
    71  	}
    72  }