mirror of
https://github.com/kaspanet/kaspad.git
synced 2025-03-30 15:08:33 +00:00
Add AppDir to args
This commit is contained in:
parent
ba163b2ee9
commit
c12731d4d4
@ -27,18 +27,21 @@ var (
|
||||
defaultLogFile = filepath.Join(defaultAppDir, defaultLogFilename)
|
||||
defaultErrLogFile = filepath.Join(defaultAppDir, defaultErrLogFilename)
|
||||
defaultRPCServer = "localhost"
|
||||
defaultDataDir = filepath.Join(config.DefaultAppDir)
|
||||
)
|
||||
|
||||
type configFlags struct {
|
||||
ShowVersion bool `short:"V" long:"version" description:"Display version information and exit"`
|
||||
RPCServer string `short:"s" long:"rpcserver" description:"RPC server to connect to"`
|
||||
Profile string `long:"profile" description:"Enable HTTP profiling on given port -- NOTE port must be between 1024 and 65536"`
|
||||
AppDir string `short:"b" long:"appdir" description:"Node datadir"`
|
||||
config.NetworkFlags
|
||||
}
|
||||
|
||||
func parseConfig() (*configFlags, error) {
|
||||
cfg := &configFlags{
|
||||
RPCServer: defaultRPCServer,
|
||||
AppDir: defaultDataDir,
|
||||
}
|
||||
parser := flags.NewParser(cfg, flags.PrintErrors|flags.HelpFlag)
|
||||
_, err := parser.Parse()
|
||||
|
@ -43,11 +43,13 @@ func main() {
|
||||
}
|
||||
|
||||
func mainImpl(cfg *configFlags) error {
|
||||
dataDir := filepath.Join(config.DefaultAppDir)
|
||||
dbPath := filepath.Join(dataDir, "kaspa-mainnet/datadir2")
|
||||
appDir := config.CleanAndExpandPath(cfg.AppDir)
|
||||
appDir = filepath.Join(appDir, cfg.NetParams().Name)
|
||||
dataDir := filepath.Join(appDir, "datadir2")
|
||||
|
||||
consensusConfig := &consensus.Config{Params: *cfg.NetParams()}
|
||||
factory := consensus.NewFactory()
|
||||
factory.SetTestDataDir(dbPath)
|
||||
factory.SetTestDataDir(dataDir)
|
||||
factory.AutoSetActivePrefix(true)
|
||||
tc, tearDownFunc, err := factory.NewTestConsensus(consensusConfig, "archiveexport")
|
||||
if err != nil {
|
||||
|
@ -149,9 +149,9 @@ type ServiceOptions struct {
|
||||
ServiceCommand string `short:"s" long:"service" description:"Service command {install, remove, start, stop}"`
|
||||
}
|
||||
|
||||
// cleanAndExpandPath expands environment variables and leading ~ in the
|
||||
// CleanAndExpandPath expands environment variables and leading ~ in the
|
||||
// passed path, cleans the result, and returns it.
|
||||
func cleanAndExpandPath(path string) string {
|
||||
func CleanAndExpandPath(path string) string {
|
||||
// Expand initial ~ to OS specific home directory.
|
||||
if strings.HasPrefix(path, "~") {
|
||||
homeDir := filepath.Dir(DefaultAppDir)
|
||||
@ -320,7 +320,7 @@ func LoadConfig() (*Config, error) {
|
||||
}
|
||||
cfg.RelayNonStd = relayNonStd
|
||||
|
||||
cfg.AppDir = cleanAndExpandPath(cfg.AppDir)
|
||||
cfg.AppDir = CleanAndExpandPath(cfg.AppDir)
|
||||
// Append the network type to the app directory so it is "namespaced"
|
||||
// per network.
|
||||
// All data is specific to a network, so namespacing the data directory
|
||||
@ -332,7 +332,7 @@ func LoadConfig() (*Config, error) {
|
||||
if cfg.LogDir == "" {
|
||||
cfg.LogDir = filepath.Join(cfg.AppDir, defaultLogDirname)
|
||||
}
|
||||
cfg.LogDir = cleanAndExpandPath(cfg.LogDir)
|
||||
cfg.LogDir = CleanAndExpandPath(cfg.LogDir)
|
||||
|
||||
// Special show command to list supported subsystems and exit.
|
||||
if cfg.LogLevel == "show" {
|
||||
|
Loading…
x
Reference in New Issue
Block a user