aboutsummaryrefslogtreecommitdiffstats
path: root/cmd
diff options
context:
space:
mode:
Diffstat (limited to 'cmd')
-rw-r--r--cmd/geth/admin.go55
-rw-r--r--cmd/geth/main.go20
m---------cmd/mist/assets/ext/ethereum.js0
-rw-r--r--cmd/utils/cmd.go8
-rw-r--r--cmd/utils/flags.go22
5 files changed, 89 insertions, 16 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()
}
diff --git a/cmd/mist/assets/ext/ethereum.js b/cmd/mist/assets/ext/ethereum.js
-Subproject 31e046dbecea51d3b99b21f3e7e60ddfb6c3930
+Subproject c80ede50c3b60a482f1ec76038325ec52f5e73b
diff --git a/cmd/utils/cmd.go b/cmd/utils/cmd.go
index feea29d64..a6140d233 100644
--- a/cmd/utils/cmd.go
+++ b/cmd/utils/cmd.go
@@ -33,10 +33,10 @@ import (
"github.com/ethereum/go-ethereum/core/types"
"github.com/ethereum/go-ethereum/eth"
"github.com/ethereum/go-ethereum/logger"
+ "github.com/ethereum/go-ethereum/logger/glog"
"github.com/ethereum/go-ethereum/rlp"
)
-var clilogger = logger.NewLogger("CLI")
var interruptCallbacks = []func(os.Signal){}
// Register interrupt handlers callbacks
@@ -50,7 +50,7 @@ func HandleInterrupt() {
go func() {
signal.Notify(c, os.Interrupt)
for sig := range c {
- clilogger.Errorf("Shutting down (%v) ... \n", sig)
+ glog.V(logger.Error).Infof("Shutting down (%v) ... \n", sig)
RunInterruptCallbacks(sig)
}
}()
@@ -113,7 +113,7 @@ func Fatalf(format string, args ...interface{}) {
}
func StartEthereum(ethereum *eth.Ethereum) {
- clilogger.Infoln("Starting ", ethereum.Name())
+ glog.V(logger.Info).Infoln("Starting ", ethereum.Name())
if err := ethereum.Start(); err != nil {
exit(err)
}
@@ -124,7 +124,7 @@ func StartEthereum(ethereum *eth.Ethereum) {
}
func StartEthereumForTest(ethereum *eth.Ethereum) {
- clilogger.Infoln("Starting ", ethereum.Name())
+ glog.V(logger.Info).Infoln("Starting ", ethereum.Name())
ethereum.StartForTest()
RegisterInterrupt(func(sig os.Signal) {
ethereum.Stop()
diff --git a/cmd/utils/flags.go b/cmd/utils/flags.go
index e82fd9c28..51844a68e 100644
--- a/cmd/utils/flags.go
+++ b/cmd/utils/flags.go
@@ -15,6 +15,7 @@ import (
"github.com/ethereum/go-ethereum/ethdb"
"github.com/ethereum/go-ethereum/event"
"github.com/ethereum/go-ethereum/logger"
+ "github.com/ethereum/go-ethereum/logger/glog"
"github.com/ethereum/go-ethereum/p2p/nat"
"github.com/ethereum/go-ethereum/rpc"
"github.com/ethereum/go-ethereum/xeth"
@@ -184,6 +185,20 @@ var (
Usage: "JS library path to be used with console and js subcommands",
Value: ".",
}
+ BacktraceAtFlag = cli.GenericFlag{
+ Name: "backtrace_at",
+ Usage: "When set to a file and line number holding a logging statement a stack trace will be written to the Info log",
+ Value: glog.GetTraceLocation(),
+ }
+ LogToStdErrFlag = cli.BoolFlag{
+ Name: "logtostderr",
+ Usage: "Logs are written to standard error instead of to files.",
+ }
+ LogVModuleFlag = cli.GenericFlag{
+ Name: "vmodule",
+ Usage: "The syntax of the argument is a comma-separated list of pattern=N, where pattern is a literal file name (minus the \".go\" suffix) or \"glob\" pattern and N is a V level.",
+ Value: glog.GetVModule(),
+ }
)
func GetNAT(ctx *cli.Context) nat.Interface {
@@ -213,6 +228,13 @@ func GetNodeKey(ctx *cli.Context) (key *ecdsa.PrivateKey) {
}
func MakeEthConfig(clientID, version string, ctx *cli.Context) *eth.Config {
+ // Set verbosity on glog
+ glog.SetV(ctx.GlobalInt(LogLevelFlag.Name))
+ // Set the log type
+ glog.SetToStderr(ctx.GlobalBool(LogToStdErrFlag.Name))
+ // Set the log dir
+ glog.SetLogDir(ctx.GlobalString(LogFileFlag.Name))
+
return &eth.Config{
Name: common.MakeName(clientID, version),
DataDir: ctx.GlobalString(DataDirFlag.Name),