diff options
-rw-r--r-- | cmd/ethereum/repl/repl.go | 2 | ||||
-rw-r--r-- | cmd/mist/bindings.go | 4 | ||||
-rw-r--r-- | cmd/mist/gui.go | 2 | ||||
-rw-r--r-- | eth/backend.go | 7 | ||||
-rw-r--r-- | ethdb/database.go | 11 | ||||
-rw-r--r-- | ethutil/config.go | 35 | ||||
-rw-r--r-- | vm/vm.go | 5 |
7 files changed, 29 insertions, 37 deletions
diff --git a/cmd/ethereum/repl/repl.go b/cmd/ethereum/repl/repl.go index ec1aa6918..05ea71e79 100644 --- a/cmd/ethereum/repl/repl.go +++ b/cmd/ethereum/repl/repl.go @@ -54,7 +54,7 @@ type JSRepl struct { } func NewJSRepl(ethereum *eth.Ethereum) *JSRepl { - hist, err := os.OpenFile(path.Join(ethutil.Config.ExecPath, "history"), os.O_RDWR|os.O_CREATE, os.ModePerm) + hist, err := os.OpenFile(path.Join(ethereum.DataDir, "history"), os.O_RDWR|os.O_CREATE, os.ModePerm) if err != nil { panic(err) } diff --git a/cmd/mist/bindings.go b/cmd/mist/bindings.go index 9623538a3..f21aa3135 100644 --- a/cmd/mist/bindings.go +++ b/cmd/mist/bindings.go @@ -79,14 +79,14 @@ func (self *Gui) AddPlugin(pluginPath string) { self.plugins[pluginPath] = plugin{Name: pluginPath, Path: pluginPath} json, _ := json.MarshalIndent(self.plugins, "", " ") - ethutil.WriteFile(ethutil.Config.ExecPath+"/plugins.json", json) + ethutil.WriteFile(self.eth.DataDir+"/plugins.json", json) } func (self *Gui) RemovePlugin(pluginPath string) { delete(self.plugins, pluginPath) json, _ := json.MarshalIndent(self.plugins, "", " ") - ethutil.WriteFile(ethutil.Config.ExecPath+"/plugins.json", json) + ethutil.WriteFile(self.eth.DataDir+"/plugins.json", json) } // this extra function needed to give int typecast value to gui widget diff --git a/cmd/mist/gui.go b/cmd/mist/gui.go index cbd8daf2f..5f444dd95 100644 --- a/cmd/mist/gui.go +++ b/cmd/mist/gui.go @@ -100,7 +100,7 @@ func NewWindow(ethereum *eth.Ethereum, config *ethutil.ConfigManager, session st plugins: make(map[string]plugin), serviceEvents: make(chan ServEv, 1), } - data, _ := ethutil.ReadAllFile(path.Join(ethutil.Config.ExecPath, "plugins.json")) + data, _ := ethutil.ReadAllFile(path.Join(ethereum.DataDir, "plugins.json")) json.Unmarshal([]byte(data), &gui.plugins) return gui diff --git a/eth/backend.go b/eth/backend.go index 88708b997..7351b4168 100644 --- a/eth/backend.go +++ b/eth/backend.go @@ -132,13 +132,15 @@ type Ethereum struct { logger logger.LogSystem - Mining bool + Mining bool + DataDir string } func New(config *Config) (*Ethereum, error) { // Boostrap database ethlogger := logger.New(config.DataDir, config.LogFile, config.LogLevel, config.LogFormat) - db, err := ethdb.NewLDBDatabase("blockchain") + + db, err := ethdb.NewLDBDatabase(path.Join(config.DataDir, "blockchain")) if err != nil { return nil, err } @@ -175,6 +177,7 @@ func New(config *Config) (*Ethereum, error) { blacklist: p2p.NewBlacklist(), eventMux: &event.TypeMux{}, logger: ethlogger, + DataDir: config.DataDir, } eth.chainManager = core.NewChainManager(db, eth.EventMux()) diff --git a/ethdb/database.go b/ethdb/database.go index f020af8f2..4e3d01da0 100644 --- a/ethdb/database.go +++ b/ethdb/database.go @@ -1,11 +1,10 @@ package ethdb import ( - "path" "fmt" - "github.com/ethereum/go-ethereum/ethutil" "github.com/ethereum/go-ethereum/compression/rle" + "github.com/ethereum/go-ethereum/ethutil" "github.com/syndtr/goleveldb/leveldb" "github.com/syndtr/goleveldb/leveldb/iterator" ) @@ -15,17 +14,13 @@ type LDBDatabase struct { comp bool } -func NewLDBDatabase(name string) (*LDBDatabase, error) { - dbPath := path.Join(ethutil.Config.ExecPath, name) - +func NewLDBDatabase(file string) (*LDBDatabase, error) { // Open the db - db, err := leveldb.OpenFile(dbPath, nil) + db, err := leveldb.OpenFile(file, nil) if err != nil { return nil, err } - database := &LDBDatabase{db: db, comp: true} - return database, nil } diff --git a/ethutil/config.go b/ethutil/config.go index fc8fb4e3f..c45c310ce 100644 --- a/ethutil/config.go +++ b/ethutil/config.go @@ -20,30 +20,27 @@ type ConfigManager struct { conf *globalconf.GlobalConf } -var Config *ConfigManager - // Read config // // Initialize Config from Config File func ReadConfig(ConfigFile string, Datadir string, EnvPrefix string) *ConfigManager { - if Config == nil { - // create ConfigFile if does not exist, otherwise globalconf panic when trying to persist flags - if !FileExist(ConfigFile) { - fmt.Printf("config file '%s' doesn't exist, creating it\n", ConfigFile) - os.Create(ConfigFile) - } - g, err := globalconf.NewWithOptions(&globalconf.Options{ - Filename: ConfigFile, - EnvPrefix: EnvPrefix, - }) - if err != nil { - fmt.Println(err) - } else { - g.ParseAll() - } - Config = &ConfigManager{ExecPath: Datadir, Debug: true, conf: g, Paranoia: true} + if !FileExist(ConfigFile) { + // create ConfigFile if it does not exist, otherwise + // globalconf will panic when trying to persist flags. + fmt.Printf("config file '%s' doesn't exist, creating it\n", ConfigFile) + os.Create(ConfigFile) + } + g, err := globalconf.NewWithOptions(&globalconf.Options{ + Filename: ConfigFile, + EnvPrefix: EnvPrefix, + }) + if err != nil { + fmt.Println(err) + } else { + g.ParseAll() } - return Config + cfg := &ConfigManager{ExecPath: Datadir, Debug: true, conf: g, Paranoia: true} + return cfg } // provides persistence for flags @@ -30,10 +30,7 @@ type Vm struct { func New(env Environment) *Vm { lt := LogTyPretty - if ethutil.Config.Diff { - lt = LogTyDiff - } - + // lt = LogTyDiff return &Vm{debug: true, env: env, logTy: lt, Recoverable: true} } |