cmd/evm: use utils.BigFlag

This commit is contained in:
Felix Lange 2017-02-22 15:03:13 +01:00
parent 4f76e1e5c1
commit 8fd6e8043a

View file

@ -20,13 +20,13 @@ package main
import ( import (
"fmt" "fmt"
"io/ioutil" "io/ioutil"
"math/big"
"os" "os"
goruntime "runtime" goruntime "runtime"
"time" "time"
"github.com/ethereum/go-ethereum/cmd/utils" "github.com/ethereum/go-ethereum/cmd/utils"
"github.com/ethereum/go-ethereum/common" "github.com/ethereum/go-ethereum/common"
"github.com/ethereum/go-ethereum/common/math"
"github.com/ethereum/go-ethereum/core/state" "github.com/ethereum/go-ethereum/core/state"
"github.com/ethereum/go-ethereum/core/vm" "github.com/ethereum/go-ethereum/core/vm"
"github.com/ethereum/go-ethereum/core/vm/runtime" "github.com/ethereum/go-ethereum/core/vm/runtime"
@ -52,20 +52,20 @@ var (
Name: "codefile", Name: "codefile",
Usage: "file containing EVM code", Usage: "file containing EVM code",
} }
GasFlag = cli.StringFlag{ GasFlag = cli.Uint64Flag{
Name: "gas", Name: "gas",
Usage: "gas limit for the evm", Usage: "gas limit for the evm",
Value: "10000000000", Value: 10000000000,
} }
PriceFlag = cli.StringFlag{ PriceFlag = utils.BigFlag{
Name: "price", Name: "price",
Usage: "price set for the evm", Usage: "price set for the evm",
Value: "0", Value: new(big.Int),
} }
ValueFlag = cli.StringFlag{ ValueFlag = utils.BigFlag{
Name: "value", Name: "value",
Usage: "value set for the evm", Usage: "value set for the evm",
Value: "0", Value: new(big.Int),
} }
DumpFlag = cli.BoolFlag{ DumpFlag = cli.BoolFlag{
Name: "dump", Name: "dump",
@ -161,9 +161,9 @@ func run(ctx *cli.Context) error {
ret, _, err = runtime.Create(input, &runtime.Config{ ret, _, err = runtime.Create(input, &runtime.Config{
Origin: sender.Address(), Origin: sender.Address(),
State: statedb, State: statedb,
GasLimit: math.MustParseUint64(ctx.GlobalString(GasFlag.Name)), GasLimit: ctx.GlobalUint64(GasFlag.Name),
GasPrice: math.MustParseBig(ctx.GlobalString(PriceFlag.Name)), GasPrice: utils.GlobalBig(ctx, PriceFlag.Name),
Value: math.MustParseBig(ctx.GlobalString(ValueFlag.Name)), Value: utils.GlobalBig(ctx, ValueFlag.Name),
EVMConfig: vm.Config{ EVMConfig: vm.Config{
Tracer: logger, Tracer: logger,
Debug: ctx.GlobalBool(DebugFlag.Name), Debug: ctx.GlobalBool(DebugFlag.Name),
@ -178,9 +178,9 @@ func run(ctx *cli.Context) error {
ret, err = runtime.Call(receiverAddress, common.Hex2Bytes(ctx.GlobalString(InputFlag.Name)), &runtime.Config{ ret, err = runtime.Call(receiverAddress, common.Hex2Bytes(ctx.GlobalString(InputFlag.Name)), &runtime.Config{
Origin: sender.Address(), Origin: sender.Address(),
State: statedb, State: statedb,
GasLimit: math.MustParseUint64(ctx.GlobalString(GasFlag.Name)), GasLimit: ctx.GlobalUint64(GasFlag.Name),
GasPrice: math.MustParseBig(ctx.GlobalString(PriceFlag.Name)), GasPrice: utils.GlobalBig(ctx, PriceFlag.Name),
Value: math.MustParseBig(ctx.GlobalString(ValueFlag.Name)), Value: utils.GlobalBig(ctx, ValueFlag.Name),
EVMConfig: vm.Config{ EVMConfig: vm.Config{
Tracer: logger, Tracer: logger,
Debug: ctx.GlobalBool(DebugFlag.Name), Debug: ctx.GlobalBool(DebugFlag.Name),