diff options
Diffstat (limited to 'cmd/utils')
-rw-r--r-- | cmd/utils/cmd.go | 35 | ||||
-rw-r--r-- | cmd/utils/customflags.go | 4 | ||||
-rw-r--r-- | cmd/utils/customflags_test.go | 4 | ||||
-rw-r--r-- | cmd/utils/flags.go | 31 | ||||
-rw-r--r-- | cmd/utils/legalese.go | 41 |
5 files changed, 85 insertions, 30 deletions
diff --git a/cmd/utils/cmd.go b/cmd/utils/cmd.go index 2949d2470..d9c4b6da5 100644 --- a/cmd/utils/cmd.go +++ b/cmd/utils/cmd.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/>. // Package utils contains internal helper functions for go-ethereum commands. package utils @@ -58,15 +58,16 @@ func PromptConfirm(prompt string) (bool, error) { ) prompt = prompt + " [y/N] " - if liner.TerminalSupported() { - lr := liner.NewLiner() - defer lr.Close() - input, err = lr.Prompt(prompt) - } else { - fmt.Print(prompt) - input, err = bufio.NewReader(os.Stdin).ReadString('\n') - fmt.Println() - } + // if liner.TerminalSupported() { + // fmt.Println("term") + // lr := liner.NewLiner() + // defer lr.Close() + // input, err = lr.Prompt(prompt) + // } else { + fmt.Print(prompt) + input, err = bufio.NewReader(os.Stdin).ReadString('\n') + fmt.Println() + // } if len(input) > 0 && strings.ToUpper(input[:1]) == "Y" { return true, nil @@ -92,12 +93,12 @@ func PromptPassword(prompt string, warnTerm bool) (string, error) { return input, err } -func initDataDir(Datadir string) { - _, err := os.Stat(Datadir) - if err != nil { - if os.IsNotExist(err) { - fmt.Printf("Data directory '%s' doesn't exist, creating it\n", Datadir) - os.Mkdir(Datadir, 0777) +func CheckLegalese(datadir string) { + // check "first run" + if !common.FileExist(datadir) { + r, _ := PromptConfirm(legalese) + if !r { + Fatalf("Must accept to continue. Shutting down...\n") } } } diff --git a/cmd/utils/customflags.go b/cmd/utils/customflags.go index 6aeec448c..e7efed4e3 100644 --- a/cmd/utils/customflags.go +++ b/cmd/utils/customflags.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/>. package utils diff --git a/cmd/utils/customflags_test.go b/cmd/utils/customflags_test.go index 726d1ab47..0fb0af63b 100644 --- a/cmd/utils/customflags_test.go +++ b/cmd/utils/customflags_test.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/>. package utils diff --git a/cmd/utils/flags.go b/cmd/utils/flags.go index 903c97e71..b66fe24cc 100644 --- a/cmd/utils/flags.go +++ b/cmd/utils/flags.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/>. package utils @@ -114,6 +114,10 @@ var ( Usage: "Sets the genesis nonce", Value: 42, } + GenesisFileFlag = cli.StringFlag{ + Name: "genesis", + Usage: "Inserts/Overwrites the genesis block (json format)", + } IdentityFlag = cli.StringFlag{ Name: "identity", Usage: "Custom node name", @@ -122,6 +126,11 @@ var ( Name: "natspec", Usage: "Enable NatSpec confirmation notice", } + CacheFlag = cli.IntFlag{ + Name: "cache", + Usage: "Megabytes of memory allocated to internal caching", + Value: 0, + } // miner settings MinerThreadsFlag = cli.IntFlag{ @@ -145,7 +154,7 @@ var ( GasPriceFlag = cli.StringFlag{ Name: "gasprice", Usage: "Sets the minimal gasprice when mining transactions", - Value: new(big.Int).Mul(big.NewInt(1), common.Szabo).String(), + Value: new(big.Int).Mul(big.NewInt(500), common.Shannon).String(), } UnlockedAccountFlag = cli.StringFlag{ @@ -378,7 +387,9 @@ func MakeEthConfig(clientID, version string, ctx *cli.Context) *eth.Config { Name: common.MakeName(clientID, version), DataDir: ctx.GlobalString(DataDirFlag.Name), GenesisNonce: ctx.GlobalInt(GenesisNonceFlag.Name), + GenesisFile: ctx.GlobalString(GenesisFileFlag.Name), BlockChainVersion: ctx.GlobalInt(BlockchainVersionFlag.Name), + DatabaseCache: ctx.GlobalInt(CacheFlag.Name), SkipBcVersionCheck: false, NetworkId: ctx.GlobalInt(NetworkIdFlag.Name), LogFile: ctx.GlobalString(LogFileFlag.Name), @@ -420,22 +431,24 @@ func SetupLogger(ctx *cli.Context) { // MakeChain creates a chain manager from set command line flags. func MakeChain(ctx *cli.Context) (chain *core.ChainManager, blockDB, stateDB, extraDB common.Database) { - dd := ctx.GlobalString(DataDirFlag.Name) + datadir := ctx.GlobalString(DataDirFlag.Name) + cache := ctx.GlobalInt(CacheFlag.Name) + var err error - if blockDB, err = ethdb.NewLDBDatabase(filepath.Join(dd, "blockchain")); err != nil { + if blockDB, err = ethdb.NewLDBDatabase(filepath.Join(datadir, "blockchain"), cache); err != nil { Fatalf("Could not open database: %v", err) } - if stateDB, err = ethdb.NewLDBDatabase(filepath.Join(dd, "state")); err != nil { + if stateDB, err = ethdb.NewLDBDatabase(filepath.Join(datadir, "state"), cache); err != nil { Fatalf("Could not open database: %v", err) } - if extraDB, err = ethdb.NewLDBDatabase(filepath.Join(dd, "extra")); err != nil { + if extraDB, err = ethdb.NewLDBDatabase(filepath.Join(datadir, "extra"), cache); err != nil { Fatalf("Could not open database: %v", err) } eventMux := new(event.TypeMux) pow := ethash.New() - genesis := core.GenesisBlock(uint64(ctx.GlobalInt(GenesisNonceFlag.Name)), blockDB) - chain, err = core.NewChainManager(genesis, blockDB, stateDB, extraDB, pow, eventMux) + //genesis := core.GenesisBlock(uint64(ctx.GlobalInt(GenesisNonceFlag.Name)), blockDB) + chain, err = core.NewChainManager(blockDB, stateDB, extraDB, pow, eventMux) if err != nil { Fatalf("Could not start chainmanager: %v", err) } diff --git a/cmd/utils/legalese.go b/cmd/utils/legalese.go new file mode 100644 index 000000000..09e687c17 --- /dev/null +++ b/cmd/utils/legalese.go @@ -0,0 +1,41 @@ +// Copyright 2015 The go-ethereum Authors +// This file is part of go-ethereum. +// +// go-ethereum is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// 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 +// 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/>. + +package utils + +const ( + legalese = ` +======================================= +Disclaimer of Liabilites and Warranties +======================================= + +THE USER EXPRESSLY KNOWS AND AGREES THAT THE USER IS USING THE ETHEREUM PLATFORM AT THE USER’S SOLE +RISK. THE USER REPRESENTS THAT THE USER HAS AN ADEQUATE UNDERSTANDING OF THE RISKS, USAGE AND +INTRICACIES OF CRYPTOGRAPHIC TOKENS AND BLOCKCHAIN-BASED OPEN SOURCE SOFTWARE, ETH PLATFORM AND ETH. +THE USER ACKNOWLEDGES AND AGREES THAT, TO THE FULLEST EXTENT PERMITTED BY ANY APPLICABLE LAW, THE +DISCLAIMERS OF LIABILITY CONTAINED HEREIN APPLY TO ANY AND ALL DAMAGES OR INJURY WHATSOEVER CAUSED +BY OR RELATED TO RISKS OF, USE OF, OR INABILITY TO USE, ETH OR THE ETHEREUM PLATFORM UNDER ANY CAUSE +OR ACTION WHATSOEVER OF ANY KIND IN ANY JURISDICTION, INCLUDING, WITHOUT LIMITATION, ACTIONS FOR +BREACH OF WARRANTY, BREACH OF CONTRACT OR TORT (INCLUDING NEGLIGENCE) AND THAT NEITHER STIFTUNG +ETHEREUM NOR ETHEREUM TEAM SHALL BE LIABLE FOR ANY INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY OR +CONSEQUENTIAL DAMAGES, INCLUDING FOR LOSS OF PROFITS, GOODWILL OR DATA. SOME JURISDICTIONS DO NOT +ALLOW THE EXCLUSION OF CERTAIN WARRANTIES OR THE LIMITATION OR EXCLUSION OF LIABILITY FOR CERTAIN +TYPES OF DAMAGES. THEREFORE, SOME OF THE ABOVE LIMITATIONS IN THIS SECTION MAY NOT APPLY TO A USER. +IN PARTICULAR, NOTHING IN THESE TERMS SHALL AFFECT THE STATUTORY RIGHTS OF ANY USER OR EXCLUDE +INJURY ARISING FROM ANY WILLFUL MISCONDUCT OR FRAUD OF STIFTUNG ETHEREUM. + +Do you accept this agreement?` +) |