From 0636c889f5fdace0ff489914a8f34191e818b4e5 Mon Sep 17 00:00:00 2001 From: Roy Lee Date: Wed, 23 May 2018 14:25:07 -0700 Subject: [PATCH] [lbry] misc: rename btc{d,ctl,wallet} chain{d,ctl,wallet} Currently, we only change the places where they impact runtime. Mostly are filenames or paths for executables and databases. Docs and other textual changes will be updated later to reduce conflicts when we rebase. rename --- Dockerfile | 2 +- cmd/addblock/config.go | 2 +- cmd/btcctl/config.go | 12 ++++++------ cmd/findcheckpoint/config.go | 2 +- config.go | 8 ++++---- config_test.go | 8 ++++---- database/cmd/dbtool/globalconfig.go | 2 +- docs/json_rpc_api.md | 6 +++--- integration/rpctest/btcd.go | 2 +- integration/rpctest/node.go | 2 +- integration/rpctest/rpc_harness.go | 2 +- rpcclient/examples/btcdwebsockets/main.go | 2 +- rpcclient/examples/btcwalletwebsockets/main.go | 4 ++-- sample-btcd.conf => sample-chain.conf | 0 upgrade.go | 10 +++++----- 15 files changed, 32 insertions(+), 32 deletions(-) rename sample-btcd.conf => sample-chain.conf (100%) diff --git a/Dockerfile b/Dockerfile index 3bbc2571..70fd1144 100644 --- a/Dockerfile +++ b/Dockerfile @@ -38,4 +38,4 @@ VOLUME ["/root/.btcd"] EXPOSE 8333 8334 -ENTRYPOINT ["btcd"] +ENTRYPOINT ["chain"] diff --git a/cmd/addblock/config.go b/cmd/addblock/config.go index 90620c8f..58cef484 100644 --- a/cmd/addblock/config.go +++ b/cmd/addblock/config.go @@ -24,7 +24,7 @@ const ( ) var ( - btcdHomeDir = btcutil.AppDataDir("btcd", false) + btcdHomeDir = btcutil.AppDataDir("chain", false) defaultDataDir = filepath.Join(btcdHomeDir, "data") knownDbTypes = database.SupportedDrivers() activeNetParams = &chaincfg.MainNetParams diff --git a/cmd/btcctl/config.go b/cmd/btcctl/config.go index 1cc2a260..369aafe5 100644 --- a/cmd/btcctl/config.go +++ b/cmd/btcctl/config.go @@ -27,10 +27,10 @@ const ( ) var ( - btcdHomeDir = btcutil.AppDataDir("btcd", false) - btcctlHomeDir = btcutil.AppDataDir("btcctl", false) - btcwalletHomeDir = btcutil.AppDataDir("btcwallet", false) - defaultConfigFile = filepath.Join(btcctlHomeDir, "btcctl.conf") + btcdHomeDir = btcutil.AppDataDir("chain", false) + btcctlHomeDir = btcutil.AppDataDir("chainctl", false) + btcwalletHomeDir = btcutil.AppDataDir("chainwallet", false) + defaultConfigFile = filepath.Join(btcctlHomeDir, "chainctl.conf") defaultRPCServer = "localhost" defaultRPCCertFile = filepath.Join(btcdHomeDir, "rpc.cert") defaultWalletCertFile = filepath.Join(btcwalletHomeDir, "rpc.cert") @@ -231,9 +231,9 @@ func loadConfig() (*config, []string, error) { // Use config file for RPC server to create default btcctl config var serverConfigPath string if preCfg.Wallet { - serverConfigPath = filepath.Join(btcwalletHomeDir, "btcwallet.conf") + serverConfigPath = filepath.Join(btcwalletHomeDir, "chainwallet.conf") } else { - serverConfigPath = filepath.Join(btcdHomeDir, "btcd.conf") + serverConfigPath = filepath.Join(btcdHomeDir, "chain.conf") } err := createDefaultConfigFile(preCfg.ConfigFile, serverConfigPath) diff --git a/cmd/findcheckpoint/config.go b/cmd/findcheckpoint/config.go index 87f04cec..d0a83bbc 100644 --- a/cmd/findcheckpoint/config.go +++ b/cmd/findcheckpoint/config.go @@ -25,7 +25,7 @@ const ( ) var ( - btcdHomeDir = btcutil.AppDataDir("btcd", false) + btcdHomeDir = btcutil.AppDataDir("chain", false) defaultDataDir = filepath.Join(btcdHomeDir, "data") knownDbTypes = database.SupportedDrivers() activeNetParams = &chaincfg.MainNetParams diff --git a/config.go b/config.go index 7124fe92..728a02c5 100644 --- a/config.go +++ b/config.go @@ -35,11 +35,11 @@ import ( ) const ( - defaultConfigFilename = "btcd.conf" + defaultConfigFilename = "chain.conf" defaultDataDirname = "data" defaultLogLevel = "info" defaultLogDirname = "logs" - defaultLogFilename = "btcd.log" + defaultLogFilename = "chain.log" defaultMaxPeers = 125 defaultBanDuration = time.Hour * 24 defaultBanThreshold = 100 @@ -62,13 +62,13 @@ const ( defaultMaxOrphanTransactions = 100 defaultMaxOrphanTxSize = 100000 defaultSigCacheMaxSize = 100000 - sampleConfigFilename = "sample-btcd.conf" + sampleConfigFilename = "sample-chain.conf" defaultTxIndex = false defaultAddrIndex = false ) var ( - defaultHomeDir = btcutil.AppDataDir("btcd", false) + defaultHomeDir = btcutil.AppDataDir("chain", false) defaultConfigFile = filepath.Join(defaultHomeDir, defaultConfigFilename) defaultDataDir = filepath.Join(defaultHomeDir, defaultDataDirname) knownDbTypes = database.SupportedDrivers() diff --git a/config_test.go b/config_test.go index e54a9f5f..484e151c 100644 --- a/config_test.go +++ b/config_test.go @@ -20,16 +20,16 @@ func TestCreateDefaultConfigFile(t *testing.T) { if !ok { t.Fatalf("Failed finding config file path") } - sampleConfigFile := filepath.Join(filepath.Dir(path), "sample-btcd.conf") + sampleConfigFile := filepath.Join(filepath.Dir(path), "sample-chain.conf") // Setup a temporary directory - tmpDir, err := ioutil.TempDir("", "btcd") + tmpDir, err := ioutil.TempDir("", "chain") if err != nil { t.Fatalf("Failed creating a temporary directory: %v", err) } testpath := filepath.Join(tmpDir, "test.conf") - // copy config file to location of btcd binary + // copy config file to location of chain binary data, err := ioutil.ReadFile(sampleConfigFile) if err != nil { t.Fatalf("Failed reading sample config file: %v", err) @@ -38,7 +38,7 @@ func TestCreateDefaultConfigFile(t *testing.T) { if err != nil { t.Fatalf("Failed obtaining app path: %v", err) } - tmpConfigFile := filepath.Join(appPath, "sample-btcd.conf") + tmpConfigFile := filepath.Join(appPath, "sample-chain.conf") err = ioutil.WriteFile(tmpConfigFile, data, 0644) if err != nil { t.Fatalf("Failed copying sample config file: %v", err) diff --git a/database/cmd/dbtool/globalconfig.go b/database/cmd/dbtool/globalconfig.go index aa1e0e04..d80d0982 100644 --- a/database/cmd/dbtool/globalconfig.go +++ b/database/cmd/dbtool/globalconfig.go @@ -18,7 +18,7 @@ import ( ) var ( - btcdHomeDir = btcutil.AppDataDir("btcd", false) + btcdHomeDir = btcutil.AppDataDir("chain", false) knownDbTypes = database.SupportedDrivers() activeNetParams = &chaincfg.MainNetParams diff --git a/docs/json_rpc_api.md b/docs/json_rpc_api.md index db292d2b..da90e85d 100644 --- a/docs/json_rpc_api.md +++ b/docs/json_rpc_api.md @@ -1107,7 +1107,7 @@ func main() { // Load the certificate for the TLS connection which is automatically // generated by btcd when it starts the RPC server and doesn't already // have one. - btcdHomeDir := btcutil.AppDataDir("btcd", false) + btcdHomeDir := btcutil.AppDataDir("chain", false) certs, err := ioutil.ReadFile(filepath.Join(btcdHomeDir, "rpc.cert")) if err != nil { log.Fatal(err) @@ -1171,7 +1171,7 @@ func main() { // Load the certificate for the TLS connection which is automatically // generated by btcd when it starts the RPC server and doesn't already // have one. - btcdHomeDir := btcutil.AppDataDir("btcd", false) + btcdHomeDir := btcutil.AppDataDir("chain", false) certs, err := ioutil.ReadFile(filepath.Join(btcdHomeDir, "rpc.cert")) if err != nil { log.Fatal(err) @@ -1274,7 +1274,7 @@ func main() { // Load the certificate for the TLS connection which is automatically // generated by btcd when it starts the RPC server and doesn't already // have one. - btcdHomeDir := btcutil.AppDataDir("btcd", false) + btcdHomeDir := btcutil.AppDataDir("chain", false) certs, err := ioutil.ReadFile(filepath.Join(btcdHomeDir, "rpc.cert")) if err != nil { log.Fatal(err) diff --git a/integration/rpctest/btcd.go b/integration/rpctest/btcd.go index 29642c84..9b125cd0 100644 --- a/integration/rpctest/btcd.go +++ b/integration/rpctest/btcd.go @@ -44,7 +44,7 @@ func btcdExecutablePath() (string, error) { } // Build btcd and output an executable in a static temp path. - outputPath := filepath.Join(testDir, "btcd") + outputPath := filepath.Join(testDir, "chain") if runtime.GOOS == "windows" { outputPath += ".exe" } diff --git a/integration/rpctest/node.go b/integration/rpctest/node.go index 73dc15fc..cb9f538b 100644 --- a/integration/rpctest/node.go +++ b/integration/rpctest/node.go @@ -51,7 +51,7 @@ func newConfig(prefix, certFile, keyFile string, extra []string, var err error btcdPath, err = btcdExecutablePath() if err != nil { - btcdPath = "btcd" + btcdPath = "chain" } } diff --git a/integration/rpctest/rpc_harness.go b/integration/rpctest/rpc_harness.go index 679ae4e4..ea78f51f 100644 --- a/integration/rpctest/rpc_harness.go +++ b/integration/rpctest/rpc_harness.go @@ -531,7 +531,7 @@ func generateListeningAddresses() (string, string) { // baseDir is the directory path of the temp directory for all rpctest files. func baseDir() (string, error) { - dirPath := filepath.Join(os.TempDir(), "btcd", "rpctest") + dirPath := filepath.Join(os.TempDir(), "chain", "rpctest") err := os.MkdirAll(dirPath, 0755) return dirPath, err } diff --git a/rpcclient/examples/btcdwebsockets/main.go b/rpcclient/examples/btcdwebsockets/main.go index 56d12d82..359d2034 100644 --- a/rpcclient/examples/btcdwebsockets/main.go +++ b/rpcclient/examples/btcdwebsockets/main.go @@ -32,7 +32,7 @@ func main() { } // Connect to local btcd RPC server using websockets. - btcdHomeDir := btcutil.AppDataDir("btcd", false) + btcdHomeDir := btcutil.AppDataDir("chain", false) certs, err := ioutil.ReadFile(filepath.Join(btcdHomeDir, "rpc.cert")) if err != nil { log.Fatal(err) diff --git a/rpcclient/examples/btcwalletwebsockets/main.go b/rpcclient/examples/btcwalletwebsockets/main.go index e803138d..f6020971 100644 --- a/rpcclient/examples/btcwalletwebsockets/main.go +++ b/rpcclient/examples/btcwalletwebsockets/main.go @@ -27,8 +27,8 @@ func main() { }, } - // Connect to local btcwallet RPC server using websockets. - certHomeDir := btcutil.AppDataDir("btcwallet", false) + // Connect to local chainwallet RPC server using websockets. + certHomeDir := btcutil.AppDataDir("chainwallet", false) certs, err := ioutil.ReadFile(filepath.Join(certHomeDir, "rpc.cert")) if err != nil { log.Fatal(err) diff --git a/sample-btcd.conf b/sample-chain.conf similarity index 100% rename from sample-btcd.conf rename to sample-chain.conf diff --git a/upgrade.go b/upgrade.go index 5dec8d4c..1510c7a5 100644 --- a/upgrade.go +++ b/upgrade.go @@ -35,13 +35,13 @@ func oldBtcdHomeDir() string { // Search for Windows APPDATA first. This won't exist on POSIX OSes. appData := os.Getenv("APPDATA") if appData != "" { - return filepath.Join(appData, "btcd") + return filepath.Join(appData, "chain") } // Fall back to standard HOME directory that works for most POSIX OSes. home := os.Getenv("HOME") if home != "" { - return filepath.Join(home, ".btcd") + return filepath.Join(home, ".chain") } // In the worst case, use the current directory. @@ -96,9 +96,9 @@ func upgradeDBPaths() error { // respective networks. Check for the old database and update it to the // new path introduced with version 0.2.0 accordingly. oldDbRoot := filepath.Join(oldBtcdHomeDir(), "db") - upgradeDBPathNet(filepath.Join(oldDbRoot, "btcd.db"), "mainnet") - upgradeDBPathNet(filepath.Join(oldDbRoot, "btcd_testnet.db"), "testnet") - upgradeDBPathNet(filepath.Join(oldDbRoot, "btcd_regtest.db"), "regtest") + upgradeDBPathNet(filepath.Join(oldDbRoot, "chain.db"), "mainnet") + upgradeDBPathNet(filepath.Join(oldDbRoot, "chain_testnet.db"), "testnet") + upgradeDBPathNet(filepath.Join(oldDbRoot, "chain_regtest.db"), "regtest") // Remove the old db directory. return os.RemoveAll(oldDbRoot)