aboutsummaryrefslogtreecommitdiffstats
path: root/cmd/ethereum
diff options
context:
space:
mode:
Diffstat (limited to 'cmd/ethereum')
-rw-r--r--cmd/ethereum/cmd.go2
-rw-r--r--cmd/ethereum/flags.go8
-rw-r--r--cmd/ethereum/main.go23
-rw-r--r--cmd/ethereum/repl/repl.go8
4 files changed, 25 insertions, 16 deletions
diff --git a/cmd/ethereum/cmd.go b/cmd/ethereum/cmd.go
index 8710d6136..d8b9ea487 100644
--- a/cmd/ethereum/cmd.go
+++ b/cmd/ethereum/cmd.go
@@ -21,9 +21,9 @@ import (
"io/ioutil"
"os"
- "github.com/ethereum/go-ethereum"
"github.com/ethereum/go-ethereum/cmd/ethereum/repl"
"github.com/ethereum/go-ethereum/cmd/utils"
+ "github.com/ethereum/go-ethereum/eth"
"github.com/ethereum/go-ethereum/javascript"
)
diff --git a/cmd/ethereum/flags.go b/cmd/ethereum/flags.go
index 85aca47c3..d27b739c3 100644
--- a/cmd/ethereum/flags.go
+++ b/cmd/ethereum/flags.go
@@ -38,7 +38,8 @@ var (
StartRpc bool
StartWebSockets bool
RpcPort int
- UseUPnP bool
+ NatType string
+ PMPGateway string
OutboundPort string
ShowGenesis bool
AddPeer string
@@ -57,6 +58,7 @@ var (
DumpHash string
DumpNumber int
VmType int
+ ImportChain string
)
// flags specific to cli client
@@ -84,7 +86,8 @@ func Init() {
flag.StringVar(&KeyRing, "keyring", "", "identifier for keyring to use")
flag.StringVar(&KeyStore, "keystore", "db", "system to store keyrings: db|file (db)")
flag.StringVar(&OutboundPort, "port", "30303", "listening port")
- flag.BoolVar(&UseUPnP, "upnp", false, "enable UPnP support")
+ flag.StringVar(&NatType, "nat", "", "NAT support (UPNP|PMP) (none)")
+ flag.StringVar(&PMPGateway, "pmp", "", "Gateway IP for PMP")
flag.IntVar(&MaxPeer, "maxpeer", 30, "maximum desired peers")
flag.IntVar(&RpcPort, "rpcport", 8080, "port to start json-rpc server on")
flag.BoolVar(&StartRpc, "rpc", false, "start rpc server")
@@ -102,6 +105,7 @@ func Init() {
flag.BoolVar(&DiffTool, "difftool", false, "creates output for diff'ing. Sets LogLevel=0")
flag.StringVar(&DiffType, "diff", "all", "sets the level of diff output [vm, all]. Has no effect if difftool=false")
flag.BoolVar(&ShowGenesis, "genesis", false, "Dump the genesis block")
+ flag.StringVar(&ImportChain, "chain", "", "Imports fiven chain")
flag.BoolVar(&Dump, "dump", false, "output the ethereum state in JSON format. Sub args [number, hash]")
flag.StringVar(&DumpHash, "hash", "", "specify arg in hex")
diff --git a/cmd/ethereum/main.go b/cmd/ethereum/main.go
index 30107c145..3f9a2a838 100644
--- a/cmd/ethereum/main.go
+++ b/cmd/ethereum/main.go
@@ -21,6 +21,7 @@ import (
"fmt"
"os"
"runtime"
+ "time"
"github.com/ethereum/go-ethereum/cmd/utils"
"github.com/ethereum/go-ethereum/core/types"
@@ -38,6 +39,10 @@ var clilogger = logger.NewLogger("CLI")
func main() {
runtime.GOMAXPROCS(runtime.NumCPU())
+ defer func() {
+ logger.Flush()
+ }()
+
utils.HandleInterrupt()
// precedence: code-internal flag default < config file < environment variables < command line
@@ -69,9 +74,9 @@ func main() {
// create, import, export keys
utils.KeyTasks(keyManager, KeyRing, GenAddr, SecretFile, ExportDir, NonInteractive)
- clientIdentity := utils.NewClientIdentity(ClientIdentifier, Version, Identifier)
+ clientIdentity := utils.NewClientIdentity(ClientIdentifier, Version, Identifier, string(keyManager.PublicKey()))
- ethereum := utils.NewEthereum(db, clientIdentity, keyManager, UseUPnP, OutboundPort, MaxPeer)
+ ethereum := utils.NewEthereum(db, clientIdentity, keyManager, utils.NatType(NatType, PMPGateway), OutboundPort, MaxPeer)
if Dump {
var block *types.Block
@@ -93,9 +98,6 @@ func main() {
os.Exit(1)
}
- // block.GetRoot() does not exist
- //fmt.Printf("RLP: %x\nstate: %x\nhash: %x\n", ethutil.Rlp(block), block.GetRoot(), block.Hash())
-
// Leave the Println. This needs clean output for piping
fmt.Printf("%s\n", block.State().Dump())
@@ -112,6 +114,16 @@ func main() {
utils.StartMining(ethereum)
}
+ if len(ImportChain) > 0 {
+ start := time.Now()
+ err := utils.ImportChain(ethereum, ImportChain)
+ if err != nil {
+ clilogger.Infoln(err)
+ }
+ clilogger.Infoln("export done in", time.Since(start))
+ return
+ }
+
// better reworked as cases
if StartJsConsole {
InitJsConsole(ethereum)
@@ -131,5 +143,4 @@ func main() {
// this blocks the thread
ethereum.WaitForShutdown()
- logger.Flush()
}
diff --git a/cmd/ethereum/repl/repl.go b/cmd/ethereum/repl/repl.go
index a5146fecd..822aaa19d 100644
--- a/cmd/ethereum/repl/repl.go
+++ b/cmd/ethereum/repl/repl.go
@@ -24,7 +24,7 @@ import (
"os"
"path"
- "github.com/ethereum/go-ethereum"
+ "github.com/ethereum/go-ethereum/eth"
"github.com/ethereum/go-ethereum/ethutil"
"github.com/ethereum/go-ethereum/javascript"
"github.com/ethereum/go-ethereum/logger"
@@ -86,12 +86,6 @@ func (self *JSRepl) Stop() {
}
func (self *JSRepl) parseInput(code string) {
- defer func() {
- if r := recover(); r != nil {
- fmt.Println("[native] error", r)
- }
- }()
-
value, err := self.re.Run(code)
if err != nil {
fmt.Println(err)