Change --dbdir flag to --datadir.

This change paves the way for saving more than just the block database to
the filesystem (such as address manager data, index data, etc) where the
name "dbdir" no longer makes sense.
This commit is contained in:
Dave Collins 2013-09-13 18:02:10 -05:00
parent be3dc1837c
commit 1c9a7095b3
2 changed files with 7 additions and 7 deletions

View file

@ -394,7 +394,7 @@ func newBlockManager(s *server) *blockManager {
// loadBlockDB opens the block database and returns a handle to it. // loadBlockDB opens the block database and returns a handle to it.
func loadBlockDB() (btcdb.Db, error) { func loadBlockDB() (btcdb.Db, error) {
dbPath := filepath.Join(cfg.DbDir, activeNetParams.dbName) dbPath := filepath.Join(cfg.DataDir, activeNetParams.dbName)
log.Infof("[BMGR] Loading block database from '%s'", dbPath) log.Infof("[BMGR] Loading block database from '%s'", dbPath)
db, err := btcdb.OpenDB(cfg.DbType, dbPath) db, err := btcdb.OpenDB(cfg.DbType, dbPath)
if err != nil { if err != nil {
@ -405,7 +405,7 @@ func loadBlockDB() (btcdb.Db, error) {
} }
// Create the db if it does not exist. // Create the db if it does not exist.
err = os.MkdirAll(cfg.DbDir, 0700) err = os.MkdirAll(cfg.DataDir, 0700)
if err != nil { if err != nil {
return nil, err return nil, err
} }

View file

@ -29,7 +29,7 @@ const (
var ( var (
defaultConfigFile = filepath.Join(btcdHomeDir(), defaultConfigFilename) defaultConfigFile = filepath.Join(btcdHomeDir(), defaultConfigFilename)
defaultDbDir = filepath.Join(btcdHomeDir(), "db") defaultDataDir = filepath.Join(btcdHomeDir(), "db")
) )
// config defines the configuration options for btcd. // config defines the configuration options for btcd.
@ -38,7 +38,7 @@ var (
type config struct { type config struct {
ShowVersion bool `short:"V" long:"version" description:"Display version information and exit"` ShowVersion bool `short:"V" long:"version" description:"Display version information and exit"`
ConfigFile string `short:"C" long:"configfile" description:"Path to configuration file"` ConfigFile string `short:"C" long:"configfile" description:"Path to configuration file"`
DbDir string `short:"b" long:"dbdir" description:"Directory to store database"` DataDir string `short:"b" long:"datadir" description:"Directory to store data"`
AddPeers []string `short:"a" long:"addpeer" description:"Add a peer to connect with at startup"` 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"` ConnectPeers []string `long:"connect" description:"Connect only to the specified peers at startup"`
SeedPeer string `short:"s" long:"seedpeer" description:"Retrieve peer addresses from this peer and then disconnect"` SeedPeer string `short:"s" long:"seedpeer" description:"Retrieve peer addresses from this peer and then disconnect"`
@ -179,7 +179,7 @@ func loadConfig() (*config, []string, error) {
MaxPeers: defaultMaxPeers, MaxPeers: defaultMaxPeers,
BanDuration: defaultBanDuration, BanDuration: defaultBanDuration,
ConfigFile: defaultConfigFile, ConfigFile: defaultConfigFile,
DbDir: defaultDbDir, DataDir: defaultDataDir,
} }
// Pre-parse the command line options to see if an alternative config // Pre-parse the command line options to see if an alternative config
@ -317,7 +317,7 @@ func loadConfig() (*config, []string, error) {
// type the database is (if the specified database is a // type the database is (if the specified database is a
// file then it is sqlite3, if it is a directory assume // file then it is sqlite3, if it is a directory assume
// it is leveldb, if not found default to type _____ // it is leveldb, if not found default to type _____
dbPath := filepath.Join(cfg.DbDir, activeNetParams.dbName) dbPath := filepath.Join(cfg.DataDir, activeNetParams.dbName)
fi, err := os.Stat(dbPath) fi, err := os.Stat(dbPath)
if err == nil { if err == nil {