From 92f9a3e5fa29e0f05c81b348b87cab4f7a94f0c8 Mon Sep 17 00:00:00 2001 From: Péter Szilágyi Date: Tue, 1 Sep 2015 17:35:14 +0300 Subject: cmd, eth: support switching client modes of operation --- cmd/geth/main.go | 1 + cmd/utils/flags.go | 24 +++++++++++++++++++++--- 2 files changed, 22 insertions(+), 3 deletions(-) (limited to 'cmd') diff --git a/cmd/geth/main.go b/cmd/geth/main.go index 3422d9500..ca86fb26f 100644 --- a/cmd/geth/main.go +++ b/cmd/geth/main.go @@ -304,6 +304,7 @@ JavaScript API. See https://github.com/ethereum/go-ethereum/wiki/Javascipt-Conso utils.DataDirFlag, utils.BlockchainVersionFlag, utils.OlympicFlag, + utils.EthModeFlag, utils.EthVersionFlag, utils.CacheFlag, utils.JSpathFlag, 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 := ð.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 } -- cgit