diff options
Diffstat (limited to 'cmd/geth')
-rw-r--r-- | cmd/geth/blocktestcmd.go | 8 | ||||
-rw-r--r-- | cmd/geth/js.go | 17 | ||||
-rw-r--r-- | cmd/geth/js_test.go | 4 | ||||
-rw-r--r-- | cmd/geth/main.go | 29 |
4 files changed, 24 insertions, 34 deletions
diff --git a/cmd/geth/blocktestcmd.go b/cmd/geth/blocktestcmd.go index d3257ca4d..e0a5becdc 100644 --- a/cmd/geth/blocktestcmd.go +++ b/cmd/geth/blocktestcmd.go @@ -91,7 +91,6 @@ func runBlockTest(ctx *cli.Context) { if err != nil { utils.Fatalf("%v", err) } - defer ethereum.Stop() if rpc { fmt.Println("Block Test post state validated, starting RPC interface.") startEth(ctx, ethereum) @@ -106,7 +105,6 @@ func runOneBlockTest(ctx *cli.Context, test *tests.BlockTest) (*eth.Ethereum, er cfg.MaxPeers = 0 // disable network cfg.Shh = false // disable whisper cfg.NAT = nil // disable port mapping - ethereum, err := eth.New(cfg) if err != nil { return nil, err @@ -114,24 +112,20 @@ func runOneBlockTest(ctx *cli.Context, test *tests.BlockTest) (*eth.Ethereum, er // import the genesis block ethereum.ResetWithGenesisBlock(test.Genesis) - // import pre accounts _, err = test.InsertPreState(ethereum) if err != nil { return ethereum, fmt.Errorf("InsertPreState: %v", err) } - cm := ethereum.ChainManager() - + cm := ethereum.BlockChain() validBlocks, err := test.TryBlocksInsert(cm) if err != nil { return ethereum, fmt.Errorf("Block Test load error: %v", err) } - newDB := cm.State() if err := test.ValidatePostState(newDB); err != nil { return ethereum, fmt.Errorf("post state validation failed: %v", err) } - return ethereum, test.ValidateImportedHeaders(cm, validBlocks) } diff --git a/cmd/geth/js.go b/cmd/geth/js.go index 3e3600705..b5ec82b57 100644 --- a/cmd/geth/js.go +++ b/cmd/geth/js.go @@ -145,7 +145,7 @@ func apiWordCompleter(line string, pos int) (head string, completions []string, return begin, completionWords, end } -func newLightweightJSRE(libPath string, client comms.EthereumClient, interactive bool) *jsre { +func newLightweightJSRE(libPath string, client comms.EthereumClient, datadir string, interactive bool) *jsre { js := &jsre{ps1: "> "} js.wait = make(chan *big.Int) js.client = client @@ -161,14 +161,14 @@ func newLightweightJSRE(libPath string, client comms.EthereumClient, interactive js.prompter = dumbterm{bufio.NewReader(os.Stdin)} } else { lr := liner.NewLiner() - js.withHistory(func(hist *os.File) { lr.ReadHistory(hist) }) + js.withHistory(datadir, func(hist *os.File) { lr.ReadHistory(hist) }) lr.SetCtrlCAborts(true) js.loadAutoCompletion() lr.SetWordCompleter(apiWordCompleter) lr.SetTabCompletionStyle(liner.TabPrints) js.prompter = lr js.atexit = func() { - js.withHistory(func(hist *os.File) { hist.Truncate(0); lr.WriteHistory(hist) }) + js.withHistory(datadir, func(hist *os.File) { hist.Truncate(0); lr.WriteHistory(hist) }) lr.Close() close(js.wait) } @@ -203,14 +203,14 @@ func newJSRE(ethereum *eth.Ethereum, libPath, corsDomain string, client comms.Et js.prompter = dumbterm{bufio.NewReader(os.Stdin)} } else { lr := liner.NewLiner() - js.withHistory(func(hist *os.File) { lr.ReadHistory(hist) }) + js.withHistory(ethereum.DataDir, func(hist *os.File) { lr.ReadHistory(hist) }) lr.SetCtrlCAborts(true) js.loadAutoCompletion() lr.SetWordCompleter(apiWordCompleter) lr.SetTabCompletionStyle(liner.TabPrints) js.prompter = lr js.atexit = func() { - js.withHistory(func(hist *os.File) { hist.Truncate(0); lr.WriteHistory(hist) }) + js.withHistory(ethereum.DataDir, func(hist *os.File) { hist.Truncate(0); lr.WriteHistory(hist) }) lr.Close() close(js.wait) } @@ -433,12 +433,7 @@ func hidepassword(input string) string { } } -func (self *jsre) withHistory(op func(*os.File)) { - datadir := common.DefaultDataDir() - if self.ethereum != nil { - datadir = self.ethereum.DataDir - } - +func (self *jsre) withHistory(datadir string, op func(*os.File)) { hist, err := os.OpenFile(filepath.Join(datadir, "history"), os.O_RDWR|os.O_CREATE, os.ModePerm) if err != nil { fmt.Printf("unable to open history file: %v\n", err) diff --git a/cmd/geth/js_test.go b/cmd/geth/js_test.go index 2fd5a531d..2ad3d669c 100644 --- a/cmd/geth/js_test.go +++ b/cmd/geth/js_test.go @@ -92,7 +92,7 @@ func testREPL(t *testing.T, config func(*eth.Config)) (string, *testjethre, *eth db, _ := ethdb.NewMemDatabase() - core.WriteGenesisBlockForTesting(db, common.HexToAddress(testAddress), common.String2Big(testBalance)) + core.WriteGenesisBlockForTesting(db, core.GenesisAccount{common.HexToAddress(testAddress), common.String2Big(testBalance)}) ks := crypto.NewKeyStorePlain(filepath.Join(tmp, "keystore")) am := accounts.NewManager(ks) conf := ð.Config{ @@ -196,7 +196,7 @@ func TestBlockChain(t *testing.T) { tmpfile := filepath.Join(extmp, "export.chain") tmpfileq := strconv.Quote(tmpfile) - ethereum.ChainManager().Reset() + ethereum.BlockChain().Reset() checkEvalJSON(t, repl, `admin.exportChain(`+tmpfileq+`)`, `true`) if _, err := os.Stat(tmpfile); err != nil { diff --git a/cmd/geth/main.go b/cmd/geth/main.go index b54d85c22..1889cb2f2 100644 --- a/cmd/geth/main.go +++ b/cmd/geth/main.go @@ -48,9 +48,9 @@ import ( const ( ClientIdentifier = "Geth" - Version = "1.1.0" + Version = "1.3.0-dev" VersionMajor = 1 - VersionMinor = 1 + VersionMinor = 3 VersionPatch = 0 ) @@ -390,7 +390,7 @@ func makeDefaultExtra() []byte { } func run(ctx *cli.Context) { - utils.CheckLegalese(ctx.GlobalString(utils.DataDirFlag.Name)) + utils.CheckLegalese(utils.MustDataDir(ctx)) if ctx.GlobalBool(utils.OlympicFlag.Name) { utils.InitOlympic() } @@ -409,7 +409,7 @@ func run(ctx *cli.Context) { } func attach(ctx *cli.Context) { - utils.CheckLegalese(ctx.GlobalString(utils.DataDirFlag.Name)) + utils.CheckLegalese(utils.MustDataDir(ctx)) var client comms.EthereumClient var err error @@ -429,6 +429,7 @@ func attach(ctx *cli.Context) { repl := newLightweightJSRE( ctx.GlobalString(utils.JSpathFlag.Name), client, + ctx.GlobalString(utils.DataDirFlag.Name), true, ) @@ -441,7 +442,7 @@ func attach(ctx *cli.Context) { } func console(ctx *cli.Context) { - utils.CheckLegalese(ctx.GlobalString(utils.DataDirFlag.Name)) + utils.CheckLegalese(utils.MustDataDir(ctx)) cfg := utils.MakeEthConfig(ClientIdentifier, nodeNameVersion, ctx) cfg.ExtraData = makeExtra(ctx) @@ -475,7 +476,7 @@ func console(ctx *cli.Context) { } func execJSFiles(ctx *cli.Context) { - utils.CheckLegalese(ctx.GlobalString(utils.DataDirFlag.Name)) + utils.CheckLegalese(utils.MustDataDir(ctx)) cfg := utils.MakeEthConfig(ClientIdentifier, nodeNameVersion, ctx) ethereum, err := eth.New(cfg) @@ -502,7 +503,7 @@ func execJSFiles(ctx *cli.Context) { } func unlockAccount(ctx *cli.Context, am *accounts.Manager, addr string, i int) (addrHex, auth string) { - utils.CheckLegalese(ctx.GlobalString(utils.DataDirFlag.Name)) + utils.CheckLegalese(utils.MustDataDir(ctx)) var err error addrHex, err = utils.ParamToAddress(addr, am) @@ -527,7 +528,7 @@ func unlockAccount(ctx *cli.Context, am *accounts.Manager, addr string, i int) ( } func blockRecovery(ctx *cli.Context) { - utils.CheckLegalese(ctx.GlobalString(utils.DataDirFlag.Name)) + utils.CheckLegalese(utils.MustDataDir(ctx)) arg := ctx.Args().First() if len(ctx.Args()) < 1 && len(arg) > 0 { @@ -593,7 +594,7 @@ func startEth(ctx *cli.Context, eth *eth.Ethereum) { } func accountList(ctx *cli.Context) { - utils.CheckLegalese(ctx.GlobalString(utils.DataDirFlag.Name)) + utils.CheckLegalese(utils.MustDataDir(ctx)) am := utils.MakeAccountManager(ctx) accts, err := am.Accounts() @@ -643,7 +644,7 @@ func getPassPhrase(ctx *cli.Context, desc string, confirmation bool, i int) (pas } func accountCreate(ctx *cli.Context) { - utils.CheckLegalese(ctx.GlobalString(utils.DataDirFlag.Name)) + utils.CheckLegalese(utils.MustDataDir(ctx)) am := utils.MakeAccountManager(ctx) passphrase := getPassPhrase(ctx, "Your new account is locked with a password. Please give a password. Do not forget this password.", true, 0) @@ -655,7 +656,7 @@ func accountCreate(ctx *cli.Context) { } func accountUpdate(ctx *cli.Context) { - utils.CheckLegalese(ctx.GlobalString(utils.DataDirFlag.Name)) + utils.CheckLegalese(utils.MustDataDir(ctx)) am := utils.MakeAccountManager(ctx) arg := ctx.Args().First() @@ -672,7 +673,7 @@ func accountUpdate(ctx *cli.Context) { } func importWallet(ctx *cli.Context) { - utils.CheckLegalese(ctx.GlobalString(utils.DataDirFlag.Name)) + utils.CheckLegalese(utils.MustDataDir(ctx)) keyfile := ctx.Args().First() if len(keyfile) == 0 { @@ -694,7 +695,7 @@ func importWallet(ctx *cli.Context) { } func accountImport(ctx *cli.Context) { - utils.CheckLegalese(ctx.GlobalString(utils.DataDirFlag.Name)) + utils.CheckLegalese(utils.MustDataDir(ctx)) keyfile := ctx.Args().First() if len(keyfile) == 0 { @@ -710,7 +711,7 @@ func accountImport(ctx *cli.Context) { } func makedag(ctx *cli.Context) { - utils.CheckLegalese(ctx.GlobalString(utils.DataDirFlag.Name)) + utils.CheckLegalese(utils.MustDataDir(ctx)) args := ctx.Args() wrongArgs := func() { |