aboutsummaryrefslogtreecommitdiffstats
path: root/cmd/geth
diff options
context:
space:
mode:
Diffstat (limited to 'cmd/geth')
-rw-r--r--cmd/geth/blocktestcmd.go4
-rw-r--r--cmd/geth/chaincmd.go30
-rw-r--r--cmd/geth/js.go23
-rw-r--r--cmd/geth/js_test.go7
-rw-r--r--cmd/geth/main.go78
-rw-r--r--cmd/geth/monitorcmd.go4
6 files changed, 114 insertions, 32 deletions
diff --git a/cmd/geth/blocktestcmd.go b/cmd/geth/blocktestcmd.go
index 494a4d474..4eff82e3d 100644
--- a/cmd/geth/blocktestcmd.go
+++ b/cmd/geth/blocktestcmd.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 main
diff --git a/cmd/geth/chaincmd.go b/cmd/geth/chaincmd.go
index b23a74809..876b8c6ba 100644
--- a/cmd/geth/chaincmd.go
+++ b/cmd/geth/chaincmd.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 main
@@ -74,10 +74,10 @@ func importChain(ctx *cli.Context) {
if len(ctx.Args()) != 1 {
utils.Fatalf("This command requires an argument.")
}
- chain, blockDB, stateDB, extraDB := utils.MakeChain(ctx)
+ chain, chainDb := utils.MakeChain(ctx)
start := time.Now()
err := utils.ImportChain(chain, ctx.Args().First())
- closeAll(blockDB, stateDB, extraDB)
+ chainDb.Close()
if err != nil {
utils.Fatalf("Import error: %v", err)
}
@@ -88,7 +88,7 @@ func exportChain(ctx *cli.Context) {
if len(ctx.Args()) < 1 {
utils.Fatalf("This command requires an argument.")
}
- chain, _, _, _ := utils.MakeChain(ctx)
+ chain, _ := utils.MakeChain(ctx)
start := time.Now()
var err error
@@ -136,8 +136,8 @@ func removeDB(ctx *cli.Context) {
func upgradeDB(ctx *cli.Context) {
glog.Infoln("Upgrading blockchain database")
- chain, blockDB, stateDB, extraDB := utils.MakeChain(ctx)
- v, _ := blockDB.Get([]byte("BlockchainVersion"))
+ chain, chainDb := utils.MakeChain(ctx)
+ v, _ := chainDb.Get([]byte("BlockchainVersion"))
bcVersion := int(common.NewValue(v).Uint())
if bcVersion == 0 {
bcVersion = core.BlockChainVersion
@@ -149,15 +149,14 @@ func upgradeDB(ctx *cli.Context) {
if err := utils.ExportChain(chain, exportFile); err != nil {
utils.Fatalf("Unable to export chain for reimport %s", err)
}
- closeAll(blockDB, stateDB, extraDB)
- os.RemoveAll(filepath.Join(ctx.GlobalString(utils.DataDirFlag.Name), "blockchain"))
- os.RemoveAll(filepath.Join(ctx.GlobalString(utils.DataDirFlag.Name), "state"))
+ chainDb.Close()
+ os.RemoveAll(filepath.Join(ctx.GlobalString(utils.DataDirFlag.Name), "chaindata"))
// Import the chain file.
- chain, blockDB, stateDB, extraDB = utils.MakeChain(ctx)
- blockDB.Put([]byte("BlockchainVersion"), common.NewValue(core.BlockChainVersion).Bytes())
+ chain, chainDb = utils.MakeChain(ctx)
+ chainDb.Put([]byte("BlockchainVersion"), common.NewValue(core.BlockChainVersion).Bytes())
err := utils.ImportChain(chain, exportFile)
- closeAll(blockDB, stateDB, extraDB)
+ chainDb.Close()
if err != nil {
utils.Fatalf("Import error %v (a backup is made in %s, use the import command to import it)", err, exportFile)
} else {
@@ -167,7 +166,7 @@ func upgradeDB(ctx *cli.Context) {
}
func dump(ctx *cli.Context) {
- chain, _, stateDB, _ := utils.MakeChain(ctx)
+ chain, chainDb := utils.MakeChain(ctx)
for _, arg := range ctx.Args() {
var block *types.Block
if hashish(arg) {
@@ -180,10 +179,11 @@ func dump(ctx *cli.Context) {
fmt.Println("{}")
utils.Fatalf("block not found")
} else {
- state := state.New(block.Root(), stateDB)
+ state := state.New(block.Root(), chainDb)
fmt.Printf("%s\n", state.Dump())
}
}
+ chainDb.Close()
}
// hashish returns true for strings that look like hashes.
diff --git a/cmd/geth/js.go b/cmd/geth/js.go
index cc4c14c2e..bf56423ec 100644
--- a/cmd/geth/js.go
+++ b/cmd/geth/js.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 main
@@ -23,6 +23,7 @@ import (
"os"
"os/signal"
"path/filepath"
+ "regexp"
"strings"
"sort"
@@ -44,6 +45,10 @@ import (
"github.com/robertkrimen/otto"
)
+var passwordRegexp = regexp.MustCompile("personal.[nu]")
+
+const passwordRepl = ""
+
type prompter interface {
AppendHistory(string)
Prompt(p string) (string, error)
@@ -413,8 +418,10 @@ func (self *jsre) interactive() {
str += input + "\n"
self.setIndent()
if indentCount <= 0 {
- hist := str[:len(str)-1]
- self.AppendHistory(hist)
+ hist := hidepassword(str[:len(str)-1])
+ if len(hist) > 0 {
+ self.AppendHistory(hist)
+ }
self.parseInput(str)
str = ""
}
@@ -422,6 +429,14 @@ func (self *jsre) interactive() {
}
}
+func hidepassword(input string) string {
+ if passwordRegexp.MatchString(input) {
+ return passwordRepl
+ } else {
+ return input
+ }
+}
+
func (self *jsre) withHistory(op func(*os.File)) {
datadir := common.DefaultDataDir()
if self.ethereum != nil {
diff --git a/cmd/geth/js_test.go b/cmd/geth/js_test.go
index ffd164d27..67c36dfe7 100644
--- a/cmd/geth/js_test.go
+++ b/cmd/geth/js_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 main
@@ -159,7 +159,7 @@ func TestAccounts(t *testing.T) {
defer os.RemoveAll(tmp)
checkEvalJSON(t, repl, `eth.accounts`, `["`+testAddress+`"]`)
- checkEvalJSON(t, repl, `eth.coinbase`, `null`)
+ checkEvalJSON(t, repl, `eth.coinbase`, `"`+testAddress+`"`)
val, err := repl.re.Run(`personal.newAccount("password")`)
if err != nil {
t.Errorf("expected no error, got %v", err)
@@ -170,6 +170,7 @@ func TestAccounts(t *testing.T) {
}
checkEvalJSON(t, repl, `eth.accounts`, `["`+testAddress+`","`+addr+`"]`)
+
}
func TestBlockChain(t *testing.T) {
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>`)
diff --git a/cmd/geth/monitorcmd.go b/cmd/geth/monitorcmd.go
index affe3b75d..a7c099532 100644
--- a/cmd/geth/monitorcmd.go
+++ b/cmd/geth/monitorcmd.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 main