mirror of
https://github.com/kaspanet/kaspad.git
synced 2025-03-30 15:08:33 +00:00
Restructure the default ~/.kaspad directory layout (#1613)
This commit is contained in:
parent
b84080f3d9
commit
1a4161ffc0
@ -171,7 +171,7 @@ func doUpgrades() error {
|
||||
|
||||
// dbPath returns the path to the block database given a database type.
|
||||
func databasePath(cfg *config.Config) string {
|
||||
return filepath.Join(cfg.DataDir, "db")
|
||||
return filepath.Join(cfg.HomeDir, "data")
|
||||
}
|
||||
|
||||
func removeDatabase(cfg *config.Config) error {
|
||||
|
@ -58,10 +58,9 @@ var (
|
||||
DefaultHomeDir = util.AppDataDir("kaspad", false)
|
||||
|
||||
defaultConfigFile = filepath.Join(DefaultHomeDir, defaultConfigFilename)
|
||||
defaultDataDir = filepath.Join(DefaultHomeDir, defaultDataDirname)
|
||||
defaultDataDir = filepath.Join(DefaultHomeDir)
|
||||
defaultRPCKeyFile = filepath.Join(DefaultHomeDir, "rpc.key")
|
||||
defaultRPCCertFile = filepath.Join(DefaultHomeDir, "rpc.cert")
|
||||
defaultLogDir = filepath.Join(DefaultHomeDir, defaultLogDirname)
|
||||
)
|
||||
|
||||
// RunServiceCommand is only set to a real function on Windows. It is used
|
||||
@ -74,7 +73,7 @@ var RunServiceCommand func(string) error
|
||||
type Flags struct {
|
||||
ShowVersion bool `short:"V" long:"version" description:"Display version information and exit"`
|
||||
ConfigFile string `short:"C" long:"configfile" description:"Path to configuration file"`
|
||||
DataDir string `short:"b" long:"datadir" description:"Directory to store data"`
|
||||
HomeDir string `short:"b" long:"homedir" description:"Directory to store data"`
|
||||
LogDir string `long:"logdir" description:"Directory to log output."`
|
||||
AddPeers []string `short:"a" long:"addpeer" description:"Add a peer to connect with at startup"`
|
||||
ConnectPeers []string `long:"connect" description:"Connect only to the specified peers at startup"`
|
||||
@ -174,8 +173,7 @@ func defaultFlags() *Flags {
|
||||
RPCMaxClients: defaultMaxRPCClients,
|
||||
RPCMaxWebsockets: defaultMaxRPCWebsockets,
|
||||
RPCMaxConcurrentReqs: defaultMaxRPCConcurrentReqs,
|
||||
DataDir: defaultDataDir,
|
||||
LogDir: defaultLogDir,
|
||||
HomeDir: defaultDataDir,
|
||||
RPCKey: defaultRPCKeyFile,
|
||||
RPCCert: defaultRPCCertFile,
|
||||
BlockMaxMass: defaultBlockMaxMass,
|
||||
@ -311,19 +309,19 @@ func LoadConfig() (*Config, error) {
|
||||
}
|
||||
cfg.RelayNonStd = relayNonStd
|
||||
|
||||
// Append the network type to the data directory so it is "namespaced"
|
||||
// per network. In addition to the block database, there are other
|
||||
// pieces of data that are saved to disk such as address manager state.
|
||||
cfg.HomeDir = cleanAndExpandPath(cfg.HomeDir)
|
||||
// Append the network type to the home directory so it is "namespaced"
|
||||
// per network.
|
||||
// All data is specific to a network, so namespacing the data directory
|
||||
// means each individual piece of serialized data does not have to
|
||||
// worry about changing names per network and such.
|
||||
cfg.DataDir = cleanAndExpandPath(cfg.DataDir)
|
||||
cfg.DataDir = filepath.Join(cfg.DataDir, cfg.NetParams().Name)
|
||||
cfg.HomeDir = filepath.Join(cfg.HomeDir, cfg.NetParams().Name)
|
||||
|
||||
// Append the network type to the log directory so it is "namespaced"
|
||||
// per network in the same fashion as the data directory.
|
||||
// Logs directory is usually under the home directory, unless otherwise specified
|
||||
if cfg.LogDir == "" {
|
||||
cfg.LogDir = filepath.Join(cfg.HomeDir, defaultLogDirname)
|
||||
}
|
||||
cfg.LogDir = cleanAndExpandPath(cfg.LogDir)
|
||||
cfg.LogDir = filepath.Join(cfg.LogDir, cfg.NetParams().Name)
|
||||
|
||||
// Special show command to list supported subsystems and exit.
|
||||
if cfg.LogLevel == "show" {
|
||||
|
@ -32,7 +32,7 @@ const (
|
||||
|
||||
func setConfig(t *testing.T, harness *appHarness) {
|
||||
harness.config = commonConfig()
|
||||
harness.config.DataDir = randomDirectory(t)
|
||||
harness.config.HomeDir = randomDirectory(t)
|
||||
harness.config.Listeners = []string{harness.p2pAddress}
|
||||
harness.config.RPCListeners = []string{harness.rpcAddress}
|
||||
harness.config.UTXOIndex = harness.utxoIndex
|
||||
|
@ -1,10 +1,11 @@
|
||||
package integration
|
||||
|
||||
import (
|
||||
"github.com/kaspanet/kaspad/domain/dagconfig"
|
||||
"path/filepath"
|
||||
"testing"
|
||||
|
||||
"github.com/kaspanet/kaspad/domain/dagconfig"
|
||||
|
||||
"github.com/kaspanet/kaspad/infrastructure/db/database/ldb"
|
||||
|
||||
"github.com/kaspanet/kaspad/infrastructure/db/database"
|
||||
@ -133,6 +134,6 @@ func setDatabaseContext(t *testing.T, harness *appHarness) {
|
||||
}
|
||||
|
||||
func openDB(cfg *config.Config) (database.Database, error) {
|
||||
dbPath := filepath.Join(cfg.DataDir, "db")
|
||||
dbPath := filepath.Join(cfg.HomeDir, "db")
|
||||
return ldb.NewLevelDB(dbPath, 8)
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user