diff options
Diffstat (limited to 'cmd/geth')
-rw-r--r-- | cmd/geth/admin.go | 55 | ||||
-rw-r--r-- | cmd/geth/main.go | 20 |
2 files changed, 63 insertions, 12 deletions
diff --git a/cmd/geth/admin.go b/cmd/geth/admin.go index b217e88b5..5f1cb8c96 100644 --- a/cmd/geth/admin.go +++ b/cmd/geth/admin.go @@ -9,6 +9,7 @@ import ( "github.com/ethereum/go-ethereum/common" "github.com/ethereum/go-ethereum/core/state" "github.com/ethereum/go-ethereum/core/types" + "github.com/ethereum/go-ethereum/logger/glog" "github.com/ethereum/go-ethereum/rlp" "github.com/ethereum/go-ethereum/rpc" "github.com/ethereum/go-ethereum/xeth" @@ -25,8 +26,6 @@ func (js *jsre) adminBindings() { admin := t.Object() admin.Set("suggestPeer", js.suggestPeer) admin.Set("startRPC", js.startRPC) - admin.Set("startMining", js.startMining) - admin.Set("stopMining", js.stopMining) admin.Set("nodeInfo", js.nodeInfo) admin.Set("peers", js.peers) admin.Set("newAccount", js.newAccount) @@ -34,6 +33,58 @@ func (js *jsre) adminBindings() { admin.Set("import", js.importChain) admin.Set("export", js.exportChain) admin.Set("dumpBlock", js.dumpBlock) + admin.Set("verbosity", js.verbosity) + admin.Set("backtrace", js.backtrace) + + admin.Set("miner", struct{}{}) + t, _ = admin.Get("miner") + miner := t.Object() + miner.Set("start", js.startMining) + miner.Set("stop", js.stopMining) + miner.Set("hashrate", js.hashrate) + miner.Set("setExtra", js.setExtra) +} + +func (js *jsre) setExtra(call otto.FunctionCall) otto.Value { + extra, err := call.Argument(0).ToString() + if err != nil { + fmt.Println(err) + return otto.UndefinedValue() + } + + if len(extra) > 1024 { + fmt.Println("error: cannot exceed 1024 bytes") + return otto.UndefinedValue() + } + + js.ethereum.Miner().SetExtra([]byte(extra)) + return otto.UndefinedValue() +} + +func (js *jsre) hashrate(otto.FunctionCall) otto.Value { + return js.re.ToVal(js.ethereum.Miner().HashRate()) +} + +func (js *jsre) backtrace(call otto.FunctionCall) otto.Value { + tracestr, err := call.Argument(0).ToString() + if err != nil { + fmt.Println(err) + return otto.UndefinedValue() + } + glog.GetTraceLocation().Set(tracestr) + + return otto.UndefinedValue() +} + +func (js *jsre) verbosity(call otto.FunctionCall) otto.Value { + v, err := call.Argument(0).ToInteger() + if err != nil { + fmt.Println(err) + return otto.UndefinedValue() + } + + glog.SetV(int(v)) + return otto.UndefinedValue() } func (js *jsre) startMining(call otto.FunctionCall) otto.Value { diff --git a/cmd/geth/main.go b/cmd/geth/main.go index 2eb06d092..9437f8eb4 100644 --- a/cmd/geth/main.go +++ b/cmd/geth/main.go @@ -43,13 +43,10 @@ import ( const ( ClientIdentifier = "Geth" - Version = "0.9.5" + Version = "0.9.7" ) -var ( - clilogger = logger.NewLogger("CLI") - app = utils.NewApp(Version, "the go-ethereum command line interface") -) +var app = utils.NewApp(Version, "the go-ethereum command line interface") func init() { app.Action = run @@ -217,9 +214,6 @@ JavaScript API. See https://github.com/ethereum/go-ethereum/wiki/Javascipt-Conso utils.DataDirFlag, utils.JSpathFlag, utils.ListenPortFlag, - utils.LogFileFlag, - utils.LogJSONFlag, - utils.LogLevelFlag, utils.MaxPeersFlag, utils.EtherbaseFlag, utils.MinerThreadsFlag, @@ -234,6 +228,12 @@ JavaScript API. See https://github.com/ethereum/go-ethereum/wiki/Javascipt-Conso utils.ProtocolVersionFlag, utils.NetworkIdFlag, utils.RPCCORSDomainFlag, + utils.LogLevelFlag, + utils.BacktraceAtFlag, + utils.LogToStdErrFlag, + utils.LogVModuleFlag, + utils.LogFileFlag, + utils.LogJSONFlag, } // missing: @@ -248,6 +248,7 @@ JavaScript API. See https://github.com/ethereum/go-ethereum/wiki/Javascipt-Conso } func main() { + fmt.Printf("Welcome to the FRONTIER\n") runtime.GOMAXPROCS(runtime.NumCPU()) defer logger.Flush() if err := app.Run(os.Args); err != nil { @@ -257,7 +258,6 @@ func main() { } func run(ctx *cli.Context) { - fmt.Printf("Welcome to the FRONTIER\n") utils.HandleInterrupt() cfg := utils.MakeEthConfig(ClientIdentifier, Version, ctx) ethereum, err := eth.New(cfg) @@ -478,7 +478,7 @@ func makedag(ctx *cli.Context) { chain, _, _ := utils.GetChain(ctx) pow := ethash.New(chain) fmt.Println("making cache") - pow.UpdateCache(true) + pow.UpdateCache(0, true) fmt.Println("making DAG") pow.UpdateDAG() } |