diff options
Diffstat (limited to 'cmd/geth/main.go')
-rw-r--r-- | cmd/geth/main.go | 78 |
1 files changed, 72 insertions, 6 deletions
diff --git a/cmd/geth/main.go b/cmd/geth/main.go index 6acdff9ad..4905d502a 100644 --- a/cmd/geth/main.go +++ b/cmd/geth/main.go @@ -8,11 +8,11 @@ // // go-ethereum is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // GNU General Public License for more details. // // You should have received a copy of the GNU General Public License -// along with go-ethereum. If not, see <http://www.gnu.org/licenses/>. +// along with go-ethereum. If not, see <http://www.gnu.org/licenses/>. // geth is the official command-line client for Ethereum. package main @@ -38,9 +38,12 @@ import ( "github.com/ethereum/go-ethereum/core/types" "github.com/ethereum/go-ethereum/eth" "github.com/ethereum/go-ethereum/ethdb" + "github.com/ethereum/go-ethereum/fdtrack" "github.com/ethereum/go-ethereum/logger" "github.com/ethereum/go-ethereum/logger/glog" "github.com/ethereum/go-ethereum/metrics" + "github.com/ethereum/go-ethereum/params" + "github.com/ethereum/go-ethereum/rlp" "github.com/ethereum/go-ethereum/rpc/codec" "github.com/ethereum/go-ethereum/rpc/comms" "github.com/mattn/go-colorable" @@ -49,11 +52,14 @@ import ( const ( ClientIdentifier = "Geth" - Version = "0.9.39" + Version = "1.0.1" + VersionMajor = 1 + VersionMinor = 0 + VersionPatch = 1 ) var ( - gitCommit string // set via linker flag + gitCommit string // set via linker flagg nodeNameVersion string app *cli.App ) @@ -276,11 +282,12 @@ JavaScript API. See https://github.com/ethereum/go-ethereum/wiki/Javascipt-Conso utils.IdentityFlag, utils.UnlockedAccountFlag, utils.PasswordFileFlag, - utils.GenesisNonceFlag, utils.GenesisFileFlag, utils.BootnodesFlag, utils.DataDirFlag, utils.BlockchainVersionFlag, + utils.OlympicFlag, + utils.CacheFlag, utils.JSpathFlag, utils.ListenPortFlag, utils.MaxPeersFlag, @@ -305,6 +312,9 @@ JavaScript API. See https://github.com/ethereum/go-ethereum/wiki/Javascipt-Conso utils.ExecFlag, utils.WhisperEnabledFlag, utils.VMDebugFlag, + utils.VMForceJitFlag, + utils.VMJitCacheFlag, + utils.VMEnableJitFlag, utils.NetworkIdFlag, utils.RPCCORSDomainFlag, utils.VerbosityFlag, @@ -326,6 +336,7 @@ JavaScript API. See https://github.com/ethereum/go-ethereum/wiki/Javascipt-Conso } app.Before = func(ctx *cli.Context) error { utils.SetupLogger(ctx) + utils.SetupVM(ctx) if ctx.GlobalBool(utils.PProfEanbledFlag.Name) { utils.StartPProf(ctx) } @@ -344,8 +355,36 @@ func main() { } } +func makeDefaultExtra() []byte { + var clientInfo = struct { + Version uint + Name string + GoVersion string + Os string + }{uint(VersionMajor<<16 | VersionMinor<<8 | VersionPatch), ClientIdentifier, runtime.Version(), runtime.GOOS} + extra, err := rlp.EncodeToBytes(clientInfo) + if err != nil { + glog.V(logger.Warn).Infoln("error setting canonical miner information:", err) + } + + if uint64(len(extra)) > params.MaximumExtraDataSize.Uint64() { + glog.V(logger.Warn).Infoln("error setting canonical miner information: extra exceeds", params.MaximumExtraDataSize) + glog.V(logger.Debug).Infof("extra: %x\n", extra) + return nil + } + + return extra +} + func run(ctx *cli.Context) { + utils.CheckLegalese(ctx.GlobalString(utils.DataDirFlag.Name)) + if ctx.GlobalBool(utils.OlympicFlag.Name) { + utils.InitOlympic() + } + cfg := utils.MakeEthConfig(ClientIdentifier, nodeNameVersion, ctx) + cfg.ExtraData = makeDefaultExtra() + ethereum, err := eth.New(cfg) if err != nil { utils.Fatalf("%v", err) @@ -357,6 +396,8 @@ func run(ctx *cli.Context) { } func attach(ctx *cli.Context) { + utils.CheckLegalese(ctx.GlobalString(utils.DataDirFlag.Name)) + // Wrap the standard output with a colorified stream (windows) if isatty.IsTerminal(os.Stdout.Fd()) { if pr, pw, err := os.Pipe(); err == nil { @@ -395,6 +436,8 @@ func attach(ctx *cli.Context) { } func console(ctx *cli.Context) { + utils.CheckLegalese(ctx.GlobalString(utils.DataDirFlag.Name)) + // Wrap the standard output with a colorified stream (windows) if isatty.IsTerminal(os.Stdout.Fd()) { if pr, pw, err := os.Pipe(); err == nil { @@ -433,6 +476,8 @@ func console(ctx *cli.Context) { } func execJSFiles(ctx *cli.Context) { + utils.CheckLegalese(ctx.GlobalString(utils.DataDirFlag.Name)) + cfg := utils.MakeEthConfig(ClientIdentifier, nodeNameVersion, ctx) ethereum, err := eth.New(cfg) if err != nil { @@ -458,6 +503,8 @@ func execJSFiles(ctx *cli.Context) { } func unlockAccount(ctx *cli.Context, am *accounts.Manager, addr string, i int) (addrHex, auth string) { + utils.CheckLegalese(ctx.GlobalString(utils.DataDirFlag.Name)) + var err error addrHex, err = utils.ParamToAddress(addr, am) if err == nil { @@ -481,13 +528,17 @@ func unlockAccount(ctx *cli.Context, am *accounts.Manager, addr string, i int) ( } func blockRecovery(ctx *cli.Context) { + utils.CheckLegalese(ctx.GlobalString(utils.DataDirFlag.Name)) + arg := ctx.Args().First() if len(ctx.Args()) < 1 && len(arg) > 0 { glog.Fatal("recover requires block number or hash") } cfg := utils.MakeEthConfig(ClientIdentifier, nodeNameVersion, ctx) - blockDb, err := ethdb.NewLDBDatabase(filepath.Join(cfg.DataDir, "blockchain")) + utils.CheckLegalese(cfg.DataDir) + + blockDb, err := ethdb.NewLDBDatabase(filepath.Join(cfg.DataDir, "blockchain"), cfg.DatabaseCache) if err != nil { glog.Fatalln("could not open db:", err) } @@ -514,6 +565,9 @@ func startEth(ctx *cli.Context, eth *eth.Ethereum) { // Start Ethereum itself utils.StartEthereum(eth) + // Start logging file descriptor stats. + fdtrack.Start() + am := eth.AccountManager() account := ctx.GlobalString(utils.UnlockedAccountFlag.Name) accounts := strings.Split(account, " ") @@ -544,6 +598,8 @@ func startEth(ctx *cli.Context, eth *eth.Ethereum) { } func accountList(ctx *cli.Context) { + utils.CheckLegalese(ctx.GlobalString(utils.DataDirFlag.Name)) + am := utils.MakeAccountManager(ctx) accts, err := am.Accounts() if err != nil { @@ -592,6 +648,8 @@ func getPassPhrase(ctx *cli.Context, desc string, confirmation bool, i int) (pas } func accountCreate(ctx *cli.Context) { + utils.CheckLegalese(ctx.GlobalString(utils.DataDirFlag.Name)) + am := utils.MakeAccountManager(ctx) passphrase := getPassPhrase(ctx, "Your new account is locked with a password. Please give a password. Do not forget this password.", true, 0) acct, err := am.NewAccount(passphrase) @@ -602,6 +660,8 @@ func accountCreate(ctx *cli.Context) { } func accountUpdate(ctx *cli.Context) { + utils.CheckLegalese(ctx.GlobalString(utils.DataDirFlag.Name)) + am := utils.MakeAccountManager(ctx) arg := ctx.Args().First() if len(arg) == 0 { @@ -617,6 +677,8 @@ func accountUpdate(ctx *cli.Context) { } func importWallet(ctx *cli.Context) { + utils.CheckLegalese(ctx.GlobalString(utils.DataDirFlag.Name)) + keyfile := ctx.Args().First() if len(keyfile) == 0 { utils.Fatalf("keyfile must be given as argument") @@ -637,6 +699,8 @@ func importWallet(ctx *cli.Context) { } func accountImport(ctx *cli.Context) { + utils.CheckLegalese(ctx.GlobalString(utils.DataDirFlag.Name)) + keyfile := ctx.Args().First() if len(keyfile) == 0 { utils.Fatalf("keyfile must be given as argument") @@ -651,6 +715,8 @@ func accountImport(ctx *cli.Context) { } func makedag(ctx *cli.Context) { + utils.CheckLegalese(ctx.GlobalString(utils.DataDirFlag.Name)) + args := ctx.Args() wrongArgs := func() { utils.Fatalf(`Usage: geth makedag <block number> <outputdir>`) |