aboutsummaryrefslogtreecommitdiffstats
path: root/cmd/utils
diff options
context:
space:
mode:
authorPéter Szilágyi <peterke@gmail.com>2015-09-01 22:35:14 +0800
committerPéter Szilágyi <peterke@gmail.com>2015-10-19 15:03:09 +0800
commit92f9a3e5fa29e0f05c81b348b87cab4f7a94f0c8 (patch)
tree77a19060ee7b46cd7819894babe24130b952c4ca /cmd/utils
parent10ed107ba2001d1aabba3d319ba88c5ce6e8fdc0 (diff)
downloaddexon-92f9a3e5fa29e0f05c81b348b87cab4f7a94f0c8.tar
dexon-92f9a3e5fa29e0f05c81b348b87cab4f7a94f0c8.tar.gz
dexon-92f9a3e5fa29e0f05c81b348b87cab4f7a94f0c8.tar.bz2
dexon-92f9a3e5fa29e0f05c81b348b87cab4f7a94f0c8.tar.lz
dexon-92f9a3e5fa29e0f05c81b348b87cab4f7a94f0c8.tar.xz
dexon-92f9a3e5fa29e0f05c81b348b87cab4f7a94f0c8.tar.zst
dexon-92f9a3e5fa29e0f05c81b348b87cab4f7a94f0c8.zip
cmd, eth: support switching client modes of operation
Diffstat (limited to 'cmd/utils')
-rw-r--r--cmd/utils/flags.go24
1 files changed, 21 insertions, 3 deletions
diff --git a/cmd/utils/flags.go b/cmd/utils/flags.go
index ca9dd76fd..792fcb41d 100644
--- a/cmd/utils/flags.go
+++ b/cmd/utils/flags.go
@@ -28,6 +28,7 @@ import (
"path/filepath"
"runtime"
"strconv"
+ "strings"
"github.com/codegangsta/cli"
"github.com/ethereum/ethash"
@@ -148,9 +149,14 @@ var (
Name: "olympic",
Usage: "Use olympic style protocol",
}
+ EthModeFlag = cli.StringFlag{
+ Name: "mode",
+ Value: "archive",
+ Usage: "Client mode of operation (archive, full, light)",
+ }
EthVersionFlag = cli.IntFlag{
Name: "eth",
- Value: 62,
+ Value: 63,
Usage: "Highest eth protocol to advertise (temporary, dev option)",
}
@@ -425,12 +431,25 @@ func MakeEthConfig(clientID, version string, ctx *cli.Context) *eth.Config {
if err != nil {
glog.V(logger.Error).Infoln("WARNING: No etherbase set and no accounts found as default")
}
-
+ // Resolve the mode of opeation from the string flag
+ var clientMode eth.Mode
+ switch strings.ToLower(ctx.GlobalString(EthModeFlag.Name)) {
+ case "archive":
+ clientMode = eth.ArchiveMode
+ case "full":
+ clientMode = eth.FullMode
+ case "light":
+ clientMode = eth.LightMode
+ default:
+ glog.Fatalf("Unknown node type requested: %s", ctx.GlobalString(EthModeFlag.Name))
+ }
+ // Assemble the entire eth configuration and return
cfg := &eth.Config{
Name: common.MakeName(clientID, version),
DataDir: MustDataDir(ctx),
GenesisNonce: ctx.GlobalInt(GenesisNonceFlag.Name),
GenesisFile: ctx.GlobalString(GenesisFileFlag.Name),
+ Mode: clientMode,
BlockChainVersion: ctx.GlobalInt(BlockchainVersionFlag.Name),
DatabaseCache: ctx.GlobalInt(CacheFlag.Name),
SkipBcVersionCheck: false,
@@ -499,7 +518,6 @@ func MakeEthConfig(clientID, version string, ctx *cli.Context) *eth.Config {
glog.V(logger.Info).Infoln("dev mode enabled")
}
-
return cfg
}