aboutsummaryrefslogtreecommitdiffstats
path: root/cmd
diff options
context:
space:
mode:
Diffstat (limited to 'cmd')
-rw-r--r--cmd/evm/main.go45
-rw-r--r--cmd/geth/accountcmd.go2
-rw-r--r--cmd/utils/cmd.go10
3 files changed, 40 insertions, 17 deletions
diff --git a/cmd/evm/main.go b/cmd/evm/main.go
index e7b266d4e..aa48f6ede 100644
--- a/cmd/evm/main.go
+++ b/cmd/evm/main.go
@@ -84,11 +84,16 @@ var (
Name: "verbosity",
Usage: "sets the verbosity level",
}
+ CreateFlag = cli.BoolFlag{
+ Name: "create",
+ Usage: "indicates the action should be create rather than call",
+ }
)
func init() {
app = utils.NewApp("0.2", "the evm command line interface")
app.Flags = []cli.Flag{
+ CreateFlag,
DebugFlag,
VerbosityFlag,
ForceJitFlag,
@@ -111,8 +116,6 @@ func run(ctx *cli.Context) error {
db, _ := ethdb.NewMemDatabase()
statedb, _ := state.New(common.Hash{}, db)
sender := statedb.CreateAccount(common.StringToAddress("sender"))
- receiver := statedb.CreateAccount(common.StringToAddress("receiver"))
- receiver.SetCode(common.Hex2Bytes(ctx.GlobalString(CodeFlag.Name)))
vmenv := NewEnv(statedb, common.StringToAddress("evmuser"), common.Big(ctx.GlobalString(ValueFlag.Name)), vm.Config{
Debug: ctx.GlobalBool(DebugFlag.Name),
@@ -121,17 +124,37 @@ func run(ctx *cli.Context) error {
})
tstart := time.Now()
- ret, e := vmenv.Call(
- sender,
- receiver.Address(),
- common.Hex2Bytes(ctx.GlobalString(InputFlag.Name)),
- common.Big(ctx.GlobalString(GasFlag.Name)),
- common.Big(ctx.GlobalString(PriceFlag.Name)),
- common.Big(ctx.GlobalString(ValueFlag.Name)),
+
+ var (
+ ret []byte
+ err error
)
+
+ if ctx.GlobalBool(CreateFlag.Name) {
+ input := append(common.Hex2Bytes(ctx.GlobalString(CodeFlag.Name)), common.Hex2Bytes(ctx.GlobalString(InputFlag.Name))...)
+ ret, _, err = vmenv.Create(
+ sender,
+ input,
+ common.Big(ctx.GlobalString(GasFlag.Name)),
+ common.Big(ctx.GlobalString(PriceFlag.Name)),
+ common.Big(ctx.GlobalString(ValueFlag.Name)),
+ )
+ } else {
+ receiver := statedb.CreateAccount(common.StringToAddress("receiver"))
+ receiver.SetCode(common.Hex2Bytes(ctx.GlobalString(CodeFlag.Name)))
+ ret, err = vmenv.Call(
+ sender,
+ receiver.Address(),
+ common.Hex2Bytes(ctx.GlobalString(InputFlag.Name)),
+ common.Big(ctx.GlobalString(GasFlag.Name)),
+ common.Big(ctx.GlobalString(PriceFlag.Name)),
+ common.Big(ctx.GlobalString(ValueFlag.Name)),
+ )
+ }
vmdone := time.Since(tstart)
if ctx.GlobalBool(DumpFlag.Name) {
+ statedb.Commit()
fmt.Println(string(statedb.Dump()))
}
vm.StdErrFormat(vmenv.StructLogs())
@@ -150,8 +173,8 @@ num gc: %d
}
fmt.Printf("OUT: 0x%x", ret)
- if e != nil {
- fmt.Printf(" error: %v", e)
+ if err != nil {
+ fmt.Printf(" error: %v", err)
}
fmt.Println()
return nil
diff --git a/cmd/geth/accountcmd.go b/cmd/geth/accountcmd.go
index 1415240eb..7fea16a25 100644
--- a/cmd/geth/accountcmd.go
+++ b/cmd/geth/accountcmd.go
@@ -316,7 +316,7 @@ func accountImport(ctx *cli.Context) error {
}
key, err := crypto.LoadECDSA(keyfile)
if err != nil {
- utils.Fatalf("keyfile must be given as argument")
+ utils.Fatalf("Failed to load the private key: %v", err)
}
accman := utils.MakeAccountManager(ctx)
passphrase := getPassPhrase("Your new account is locked with a password. Please give a password. Do not forget this password.", true, 0, utils.MakePasswordList(ctx))
diff --git a/cmd/utils/cmd.go b/cmd/utils/cmd.go
index 9e2b14f56..3b521a0e1 100644
--- a/cmd/utils/cmd.go
+++ b/cmd/utils/cmd.go
@@ -120,7 +120,7 @@ func ImportChain(chain *core.BlockChain, fn string) error {
}
}
- glog.Infoln("Importing blockchain", fn)
+ glog.Infoln("Importing blockchain ", fn)
fh, err := os.Open(fn)
if err != nil {
return err
@@ -182,7 +182,7 @@ func hasAllBlocks(chain *core.BlockChain, bs []*types.Block) bool {
}
func ExportChain(blockchain *core.BlockChain, fn string) error {
- glog.Infoln("Exporting blockchain to", fn)
+ glog.Infoln("Exporting blockchain to ", fn)
fh, err := os.OpenFile(fn, os.O_CREATE|os.O_WRONLY|os.O_TRUNC, os.ModePerm)
if err != nil {
return err
@@ -191,12 +191,12 @@ func ExportChain(blockchain *core.BlockChain, fn string) error {
if err := blockchain.Export(fh); err != nil {
return err
}
- glog.Infoln("Exported blockchain to", fn)
+ glog.Infoln("Exported blockchain to ", fn)
return nil
}
func ExportAppendChain(blockchain *core.BlockChain, fn string, first uint64, last uint64) error {
- glog.Infoln("Exporting blockchain to", fn)
+ glog.Infoln("Exporting blockchain to ", fn)
// TODO verify mode perms
fh, err := os.OpenFile(fn, os.O_CREATE|os.O_APPEND|os.O_WRONLY, os.ModePerm)
if err != nil {
@@ -206,6 +206,6 @@ func ExportAppendChain(blockchain *core.BlockChain, fn string, first uint64, las
if err := blockchain.ExportN(fh, first, last); err != nil {
return err
}
- glog.Infoln("Exported blockchain to", fn)
+ glog.Infoln("Exported blockchain to ", fn)
return nil
}