parent
72c186f9a9
commit
89eae6f590
4 changed files with 22 additions and 62 deletions
|
@ -31,13 +31,17 @@ type config struct {
|
|||
InFile string `short:"i" long:"infile" description:"File containing the block(s)" required:"true"`
|
||||
}
|
||||
|
||||
var log seelog.LoggerInterface
|
||||
|
||||
const (
|
||||
ArgSha = iota
|
||||
ArgHeight
|
||||
)
|
||||
|
||||
var (
|
||||
btcdHomeDir = btcutil.AppDataDir("btcd", false)
|
||||
defaultDataDir = filepath.Join(btcdHomeDir, "data")
|
||||
log seelog.LoggerInterface
|
||||
)
|
||||
|
||||
type bufQueue struct {
|
||||
height int64
|
||||
blkbuf []byte
|
||||
|
@ -52,7 +56,7 @@ type blkQueue struct {
|
|||
func main() {
|
||||
cfg := config{
|
||||
DbType: "leveldb",
|
||||
DataDir: filepath.Join(btcdHomeDir(), "data"),
|
||||
DataDir: defaultDataDir,
|
||||
}
|
||||
parser := flags.NewParser(&cfg, flags.Default)
|
||||
_, err := parser.Parse()
|
||||
|
@ -246,21 +250,3 @@ func newLogger(level string, prefix string) seelog.LoggerInterface {
|
|||
|
||||
return logger
|
||||
}
|
||||
|
||||
// btcdHomeDir returns an OS appropriate home directory for btcd.
|
||||
func btcdHomeDir() string {
|
||||
// Search for Windows APPDATA first. This won't exist on POSIX OSes.
|
||||
appData := os.Getenv("APPDATA")
|
||||
if appData != "" {
|
||||
return filepath.Join(appData, "btcd")
|
||||
}
|
||||
|
||||
// Fall back to standard HOME directory that works for most POSIX OSes.
|
||||
home := os.Getenv("HOME")
|
||||
if home != "" {
|
||||
return filepath.Join(home, ".btcd")
|
||||
}
|
||||
|
||||
// In the worst case, use the current directory.
|
||||
return "."
|
||||
}
|
||||
|
|
|
@ -9,6 +9,7 @@ import (
|
|||
"fmt"
|
||||
"github.com/conformal/btcdb"
|
||||
_ "github.com/conformal/btcdb/ldb"
|
||||
"github.com/conformal/btcutil"
|
||||
"github.com/conformal/btcwire"
|
||||
"github.com/conformal/go-flags"
|
||||
"github.com/conformal/seelog"
|
||||
|
@ -26,7 +27,11 @@ type config struct {
|
|||
ShaString string `short:"s" description:"Block SHA to process" required:"true"`
|
||||
}
|
||||
|
||||
var log seelog.LoggerInterface
|
||||
var (
|
||||
btcdHomeDir = btcutil.AppDataDir("btcd", false)
|
||||
defaultDataDir = filepath.Join(btcdHomeDir, "data")
|
||||
log seelog.LoggerInterface
|
||||
)
|
||||
|
||||
const (
|
||||
ArgSha = iota
|
||||
|
@ -36,7 +41,7 @@ const (
|
|||
func main() {
|
||||
cfg := config{
|
||||
DbType: "leveldb",
|
||||
DataDir: filepath.Join(btcdHomeDir(), "data"),
|
||||
DataDir: defaultDataDir,
|
||||
}
|
||||
parser := flags.NewParser(&cfg, flags.Default)
|
||||
_, err := parser.Parse()
|
||||
|
@ -185,21 +190,3 @@ func parsesha(argstr string) (argtype int, height int64, psha *btcwire.ShaHash,
|
|||
psha = &sha
|
||||
return
|
||||
}
|
||||
|
||||
// btcdHomeDir returns an OS appropriate home directory for btcd.
|
||||
func btcdHomeDir() string {
|
||||
// Search for Windows APPDATA first. This won't exist on POSIX OSes.
|
||||
appData := os.Getenv("APPDATA")
|
||||
if appData != "" {
|
||||
return filepath.Join(appData, "btcd")
|
||||
}
|
||||
|
||||
// Fall back to standard HOME directory that works for most POSIX OSes.
|
||||
home := os.Getenv("HOME")
|
||||
if home != "" {
|
||||
return filepath.Join(home, ".btcd")
|
||||
}
|
||||
|
||||
// In the worst case, use the current directory.
|
||||
return "."
|
||||
}
|
||||
|
|
|
@ -23,7 +23,8 @@ const (
|
|||
)
|
||||
|
||||
var (
|
||||
defaultDataDir = filepath.Join(btcdHomeDir(), "data")
|
||||
btcdHomeDir = btcutil.AppDataDir("btcd", false)
|
||||
defaultDataDir = filepath.Join(btcdHomeDir, "data")
|
||||
knownDbTypes = btcdb.SupportedDBs()
|
||||
activeNetwork = btcwire.MainNet
|
||||
)
|
||||
|
@ -39,24 +40,6 @@ type config struct {
|
|||
UseGoOutput bool `short:"g" long:"gooutput" description:"Display the candidates using Go syntax that is ready to insert into the btcchain checkpoint list"`
|
||||
}
|
||||
|
||||
// btcdHomeDir returns an OS appropriate home directory for btcd.
|
||||
func btcdHomeDir() string {
|
||||
// Search for Windows APPDATA first. This won't exist on POSIX OSes.
|
||||
appData := os.Getenv("APPDATA")
|
||||
if appData != "" {
|
||||
return filepath.Join(appData, "btcd")
|
||||
}
|
||||
|
||||
// Fall back to standard HOME directory that works for most POSIX OSes.
|
||||
home := os.Getenv("HOME")
|
||||
if home != "" {
|
||||
return filepath.Join(home, ".btcd")
|
||||
}
|
||||
|
||||
// In the worst case, use the current directory.
|
||||
return "."
|
||||
}
|
||||
|
||||
// validDbType returns whether or not dbType is a supported database type.
|
||||
func validDbType(dbType string) bool {
|
||||
for _, knownType := range knownDbTypes {
|
||||
|
|
|
@ -36,7 +36,11 @@ type config struct {
|
|||
ShowTx bool `short:"t" description:"Show transaction"`
|
||||
}
|
||||
|
||||
var log seelog.LoggerInterface
|
||||
var (
|
||||
btcdHomeDir = btcutil.AppDataDir("btcd", false)
|
||||
defaultDataDir = filepath.Join(btcdHomeDir, "data")
|
||||
log seelog.LoggerInterface
|
||||
)
|
||||
|
||||
const (
|
||||
ArgSha = iota
|
||||
|
@ -48,7 +52,7 @@ func main() {
|
|||
|
||||
cfg := config{
|
||||
DbType: "leveldb",
|
||||
DataDir: filepath.Join(btcdHomeDir(), "data"),
|
||||
DataDir: defaultDataDir,
|
||||
}
|
||||
parser := flags.NewParser(&cfg, flags.Default)
|
||||
_, err := parser.Parse()
|
||||
|
|
Loading…
Reference in a new issue