aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorFelix Lange <fjl@twurst.com>2015-09-11 03:15:33 +0800
committerFelix Lange <fjl@twurst.com>2015-09-11 03:15:33 +0800
commit4e075e401354b4ee068cf78b1f283763fe927245 (patch)
tree09de03b1fb972223932e8a9388379bbf0e3bc6e4
parent62bbf8a09e7304611f57fb7eea92911cf52e6229 (diff)
parentf04b3a6f293ef15151dc040183ab74ef5ce54d2a (diff)
downloadgo-tangerine-4e075e401354b4ee068cf78b1f283763fe927245.tar.gz
go-tangerine-4e075e401354b4ee068cf78b1f283763fe927245.tar.zst
go-tangerine-4e075e401354b4ee068cf78b1f283763fe927245.zip
Merge pull request #1773 from obscuren/dev-mode
cmd/geth, cmd/utils, eth: added dev mode flag
-rw-r--r--cmd/geth/main.go1
-rw-r--r--cmd/utils/flags.go33
-rw-r--r--eth/backend.go15
3 files changed, 42 insertions, 7 deletions
diff --git a/cmd/geth/main.go b/cmd/geth/main.go
index aacb588fe..f72f69791 100644
--- a/cmd/geth/main.go
+++ b/cmd/geth/main.go
@@ -308,6 +308,7 @@ JavaScript API. See https://github.com/ethereum/go-ethereum/wiki/Javascipt-Conso
utils.IPCPathFlag,
utils.ExecFlag,
utils.WhisperEnabledFlag,
+ utils.DevModeFlag,
utils.VMDebugFlag,
utils.VMForceJitFlag,
utils.VMJitCacheFlag,
diff --git a/cmd/utils/flags.go b/cmd/utils/flags.go
index 80805ca22..95fb649e6 100644
--- a/cmd/utils/flags.go
+++ b/cmd/utils/flags.go
@@ -121,6 +121,10 @@ var (
Name: "genesis",
Usage: "Inserts/Overwrites the genesis block (json format)",
}
+ DevModeFlag = cli.BoolFlag{
+ Name: "dev",
+ Usage: "Developer mode. This mode creates a private network and sets several debugging flags",
+ }
IdentityFlag = cli.StringFlag{
Name: "identity",
Usage: "Custom node name",
@@ -410,7 +414,7 @@ func MakeEthConfig(clientID, version string, ctx *cli.Context) *eth.Config {
glog.V(logger.Error).Infoln("WARNING: No etherbase set and no accounts found as default")
}
- return &eth.Config{
+ cfg := &eth.Config{
Name: common.MakeName(clientID, version),
DataDir: ctx.GlobalString(DataDirFlag.Name),
GenesisNonce: ctx.GlobalInt(GenesisNonceFlag.Name),
@@ -447,6 +451,33 @@ func MakeEthConfig(clientID, version string, ctx *cli.Context) *eth.Config {
SolcPath: ctx.GlobalString(SolcPathFlag.Name),
AutoDAG: ctx.GlobalBool(AutoDAGFlag.Name) || ctx.GlobalBool(MiningEnabledFlag.Name),
}
+
+ if ctx.GlobalBool(DevModeFlag.Name) {
+ if !ctx.GlobalIsSet(VMDebugFlag.Name) {
+ cfg.VmDebug = true
+ }
+ if !ctx.GlobalIsSet(MaxPeersFlag.Name) {
+ cfg.MaxPeers = 0
+ }
+ if !ctx.GlobalIsSet(GasPriceFlag.Name) {
+ cfg.GasPrice = new(big.Int)
+ }
+ if !ctx.GlobalIsSet(ListenPortFlag.Name) {
+ cfg.Port = "0" // auto port
+ }
+ if !ctx.GlobalIsSet(WhisperEnabledFlag.Name) {
+ cfg.Shh = true
+ }
+ if !ctx.GlobalIsSet(DataDirFlag.Name) {
+ cfg.DataDir = os.TempDir() + "/ethereum_dev_mode"
+ }
+ cfg.PowTest = true
+ cfg.DevMode = true
+
+ glog.V(logger.Info).Infoln("dev mode enabled")
+ }
+
+ return cfg
}
// SetupLogger configures glog from the logging-related command line flags.
diff --git a/eth/backend.go b/eth/backend.go
index ad2a2c1f9..639aaaaec 100644
--- a/eth/backend.go
+++ b/eth/backend.go
@@ -73,6 +73,8 @@ var (
)
type Config struct {
+ DevMode bool
+
Name string
NetworkId int
GenesisNonce int
@@ -303,16 +305,17 @@ func New(config *Config) (*Ethereum, error) {
glog.V(logger.Info).Infof("Successfully wrote genesis block. New genesis hash = %x\n", block.Hash())
}
- if config.Olympic {
+ // different modes
+ switch {
+ case config.Olympic:
+ glog.V(logger.Error).Infoln("Starting Olympic network")
+ fallthrough
+ case config.DevMode:
_, err := core.WriteTestNetGenesisBlock(chainDb, 42)
if err != nil {
return nil, err
}
- glog.V(logger.Error).Infoln("Starting Olympic network")
- }
-
- // This is for testing only.
- if config.GenesisBlock != nil {
+ case config.GenesisBlock != nil: // This is for testing only.
core.WriteBlock(chainDb, config.GenesisBlock)
core.WriteHead(chainDb, config.GenesisBlock)
}