aboutsummaryrefslogtreecommitdiffstats
path: root/cmd
diff options
context:
space:
mode:
Diffstat (limited to 'cmd')
-rw-r--r--cmd/faucet/faucet.go39
-rw-r--r--cmd/geth/accountcmd.go11
-rw-r--r--cmd/geth/chaincmd.go2
-rw-r--r--cmd/geth/config.go186
-rw-r--r--cmd/geth/consolecmd_test.go36
-rw-r--r--cmd/geth/dao_test.go24
-rw-r--r--cmd/geth/main.go59
-rw-r--r--cmd/geth/usage.go4
-rw-r--r--cmd/puppeth/module_dashboard.go498
-rw-r--r--cmd/swarm/main.go38
-rw-r--r--cmd/utils/customflags.go53
-rw-r--r--cmd/utils/flags.go550
-rw-r--r--cmd/wnode/main.go1
13 files changed, 862 insertions, 639 deletions
diff --git a/cmd/faucet/faucet.go b/cmd/faucet/faucet.go
index 232f0ff9e..fd34cdec1 100644
--- a/cmd/faucet/faucet.go
+++ b/cmd/faucet/faucet.go
@@ -41,11 +41,13 @@ import (
"github.com/ethereum/go-ethereum/core"
"github.com/ethereum/go-ethereum/core/types"
"github.com/ethereum/go-ethereum/eth"
+ "github.com/ethereum/go-ethereum/eth/downloader"
"github.com/ethereum/go-ethereum/ethclient"
"github.com/ethereum/go-ethereum/ethstats"
"github.com/ethereum/go-ethereum/les"
"github.com/ethereum/go-ethereum/log"
"github.com/ethereum/go-ethereum/node"
+ "github.com/ethereum/go-ethereum/p2p"
"github.com/ethereum/go-ethereum/p2p/discover"
"github.com/ethereum/go-ethereum/p2p/discv5"
"github.com/ethereum/go-ethereum/p2p/nat"
@@ -175,32 +177,29 @@ type faucet struct {
func newFaucet(genesis *core.Genesis, port int, enodes []*discv5.Node, network int, stats string, ks *keystore.KeyStore, index []byte) (*faucet, error) {
// Assemble the raw devp2p protocol stack
stack, err := node.New(&node.Config{
- Name: "geth",
- Version: params.Version,
- DataDir: filepath.Join(os.Getenv("HOME"), ".faucet"),
- NAT: nat.Any(),
- DiscoveryV5: true,
- ListenAddr: fmt.Sprintf(":%d", port),
- DiscoveryV5Addr: fmt.Sprintf(":%d", port+1),
- MaxPeers: 25,
- BootstrapNodesV5: enodes,
+ Name: "geth",
+ Version: params.Version,
+ DataDir: filepath.Join(os.Getenv("HOME"), ".faucet"),
+ P2P: p2p.Config{
+ NAT: nat.Any(),
+ NoDiscovery: true,
+ DiscoveryV5: true,
+ ListenAddr: fmt.Sprintf(":%d", port),
+ DiscoveryV5Addr: fmt.Sprintf(":%d", port+1),
+ MaxPeers: 25,
+ BootstrapNodesV5: enodes,
+ },
})
if err != nil {
return nil, err
}
// Assemble the Ethereum light client protocol
if err := stack.Register(func(ctx *node.ServiceContext) (node.Service, error) {
- return les.New(ctx, &eth.Config{
- LightMode: true,
- NetworkId: network,
- Genesis: genesis,
- GasPrice: big.NewInt(20 * params.Shannon),
- GpoBlocks: 10,
- GpoPercentile: 50,
- EthashCacheDir: "ethash",
- EthashCachesInMem: 2,
- EthashCachesOnDisk: 3,
- })
+ cfg := eth.DefaultConfig
+ cfg.SyncMode = downloader.LightSync
+ cfg.NetworkId = network
+ cfg.Genesis = genesis
+ return les.New(ctx, &cfg)
}); err != nil {
return nil, err
}
diff --git a/cmd/geth/accountcmd.go b/cmd/geth/accountcmd.go
index f86be62ba..90f79a47e 100644
--- a/cmd/geth/accountcmd.go
+++ b/cmd/geth/accountcmd.go
@@ -179,8 +179,7 @@ nodes.
)
func accountList(ctx *cli.Context) error {
- stack := utils.MakeNode(ctx, clientIdentifier, gitCommit)
-
+ stack, _ := makeConfigNode(ctx)
var index int
for _, wallet := range stack.AccountManager().Wallets() {
for _, account := range wallet.Accounts() {
@@ -278,7 +277,7 @@ func ambiguousAddrRecovery(ks *keystore.KeyStore, err *keystore.AmbiguousAddrErr
// accountCreate creates a new account into the keystore defined by the CLI flags.
func accountCreate(ctx *cli.Context) error {
- stack := utils.MakeNode(ctx, clientIdentifier, gitCommit)
+ stack, _ := makeConfigNode(ctx)
password := getPassPhrase("Your new account is locked with a password. Please give a password. Do not forget this password.", true, 0, utils.MakePasswordList(ctx))
ks := stack.AccountManager().Backends(keystore.KeyStoreType)[0].(*keystore.KeyStore)
@@ -296,7 +295,7 @@ func accountUpdate(ctx *cli.Context) error {
if len(ctx.Args()) == 0 {
utils.Fatalf("No accounts specified to update")
}
- stack := utils.MakeNode(ctx, clientIdentifier, gitCommit)
+ stack, _ := makeConfigNode(ctx)
ks := stack.AccountManager().Backends(keystore.KeyStoreType)[0].(*keystore.KeyStore)
account, oldPassword := unlockAccount(ctx, ks, ctx.Args().First(), 0, nil)
@@ -317,7 +316,7 @@ func importWallet(ctx *cli.Context) error {
utils.Fatalf("Could not read wallet file: %v", err)
}
- stack := utils.MakeNode(ctx, clientIdentifier, gitCommit)
+ stack, _ := makeConfigNode(ctx)
passphrase := getPassPhrase("", false, 0, utils.MakePasswordList(ctx))
ks := stack.AccountManager().Backends(keystore.KeyStoreType)[0].(*keystore.KeyStore)
@@ -338,7 +337,7 @@ func accountImport(ctx *cli.Context) error {
if err != nil {
utils.Fatalf("Failed to load the private key: %v", err)
}
- stack := utils.MakeNode(ctx, clientIdentifier, gitCommit)
+ stack, _ := makeConfigNode(ctx)
passphrase := getPassPhrase("Your new account is locked with a password. Please give a password. Do not forget this password.", true, 0, utils.MakePasswordList(ctx))
ks := stack.AccountManager().Backends(keystore.KeyStoreType)[0].(*keystore.KeyStore)
diff --git a/cmd/geth/chaincmd.go b/cmd/geth/chaincmd.go
index 2d121a611..66516b409 100644
--- a/cmd/geth/chaincmd.go
+++ b/cmd/geth/chaincmd.go
@@ -244,7 +244,7 @@ func exportChain(ctx *cli.Context) error {
}
func removeDB(ctx *cli.Context) error {
- stack := utils.MakeNode(ctx, clientIdentifier, gitCommit)
+ stack, _ := makeConfigNode(ctx)
dbdir := stack.ResolvePath(utils.ChainDbName(ctx))
if !common.FileExist(dbdir) {
fmt.Println(dbdir, "does not exist")
diff --git a/cmd/geth/config.go b/cmd/geth/config.go
new file mode 100644
index 000000000..86dd4bfdf
--- /dev/null
+++ b/cmd/geth/config.go
@@ -0,0 +1,186 @@
+// 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 main
+
+import (
+ "bufio"
+ "encoding/hex"
+ "errors"
+ "fmt"
+ "io"
+ "os"
+ "reflect"
+ "unicode"
+
+ cli "gopkg.in/urfave/cli.v1"
+
+ "github.com/ethereum/go-ethereum/cmd/utils"
+ "github.com/ethereum/go-ethereum/contracts/release"
+ "github.com/ethereum/go-ethereum/eth"
+ "github.com/ethereum/go-ethereum/node"
+ "github.com/ethereum/go-ethereum/params"
+ "github.com/naoina/toml"
+)
+
+var (
+ dumpConfigCommand = cli.Command{
+ Action: dumpConfig,
+ Name: "dumpconfig",
+ Usage: "Show configuration values",
+ ArgsUsage: "",
+ Category: "MISCELLANEOUS COMMANDS",
+ Description: `The dumpconfig command shows configuration values.`,
+ }
+
+ configFileFlag = cli.StringFlag{
+ Name: "config",
+ Usage: "TOML configuration file",
+ }
+)
+
+// These settings ensure that TOML keys use the same names as Go struct fields.
+var tomlSettings = toml.Config{
+ NormFieldName: func(rt reflect.Type, key string) string {
+ return key
+ },
+ FieldToKey: func(rt reflect.Type, field string) string {
+ return field
+ },
+ MissingField: func(rt reflect.Type, field string) error {
+ link := ""
+ if unicode.IsUpper(rune(rt.Name()[0])) && rt.PkgPath() != "main" {
+ link = fmt.Sprintf(", see https://godoc.org/%s#%s for available fields", rt.PkgPath(), rt.Name())
+ }
+ return fmt.Errorf("field '%s' is not defined in %s%s", field, rt.String(), link)
+ },
+}
+
+type ethstatsConfig struct {
+ URL string `toml:",omitempty"`
+}
+
+type gethConfig struct {
+ Eth eth.Config
+ Node node.Config
+ Ethstats ethstatsConfig
+}
+
+func loadConfig(file string, cfg *gethConfig) error {
+ f, err := os.Open(file)
+ if err != nil {
+ return err
+ }
+ defer f.Close()
+
+ err = tomlSettings.NewDecoder(bufio.NewReader(f)).Decode(cfg)
+ // Add file name to errors that have a line number.
+ if _, ok := err.(*toml.LineError); ok {
+ err = errors.New(file + ", " + err.Error())
+ }
+ return err
+}
+
+func defaultNodeConfig() node.Config {
+ cfg := node.DefaultConfig
+ cfg.Name = clientIdentifier
+ cfg.Version = params.VersionWithCommit(gitCommit)
+ cfg.HTTPModules = append(cfg.HTTPModules, "eth")
+ cfg.WSModules = append(cfg.WSModules, "eth")
+ cfg.IPCPath = "geth.ipc"
+ return cfg
+}
+
+func makeConfigNode(ctx *cli.Context) (*node.Node, gethConfig) {
+ // Load defaults.
+ cfg := gethConfig{
+ Eth: eth.DefaultConfig,
+ Node: defaultNodeConfig(),
+ }
+
+ // Load config file.
+ if file := ctx.GlobalString(configFileFlag.Name); file != "" {
+ if err := loadConfig(file, &cfg); err != nil {
+ utils.Fatalf("%v", err)
+ }
+ }
+
+ // Apply flags.
+ utils.SetNodeConfig(ctx, &cfg.Node)
+ stack, err := node.New(&cfg.Node)
+ if err != nil {
+ utils.Fatalf("Failed to create the protocol stack: %v", err)
+ }
+ utils.SetEthConfig(ctx, stack, &cfg.Eth)
+ if ctx.GlobalIsSet(utils.EthStatsURLFlag.Name) {
+ cfg.Ethstats.URL = ctx.GlobalString(utils.EthStatsURLFlag.Name)
+ }
+
+ return stack, cfg
+}
+
+func makeFullNode(ctx *cli.Context) *node.Node {
+ stack, cfg := makeConfigNode(ctx)
+
+ utils.RegisterEthService(stack, &cfg.Eth)
+
+ // Whisper must be explicitly enabled, but is auto-enabled in --dev mode.
+ shhEnabled := ctx.GlobalBool(utils.WhisperEnabledFlag.Name)
+ shhAutoEnabled := !ctx.GlobalIsSet(utils.WhisperEnabledFlag.Name) && ctx.GlobalIsSet(utils.DevModeFlag.Name)
+ if shhEnabled || shhAutoEnabled {
+ utils.RegisterShhService(stack)
+ }
+
+ // Add the Ethereum Stats daemon if requested.
+ if cfg.Ethstats.URL != "" {
+ utils.RegisterEthStatsService(stack, cfg.Ethstats.URL)
+ }
+
+ // Add the release oracle service so it boots along with node.
+ if err := stack.Register(func(ctx *node.ServiceContext) (node.Service, error) {
+ config := release.Config{
+ Oracle: relOracle,
+ Major: uint32(params.VersionMajor),
+ Minor: uint32(params.VersionMinor),
+ Patch: uint32(params.VersionPatch),
+ }
+ commit, _ := hex.DecodeString(gitCommit)
+ copy(config.Commit[:], commit)
+ return release.NewReleaseService(ctx, config)
+ }); err != nil {
+ utils.Fatalf("Failed to register the Geth release oracle service: %v", err)
+ }
+ return stack
+}
+
+// dumpConfig is the dumpconfig command.
+func dumpConfig(ctx *cli.Context) error {
+ _, cfg := makeConfigNode(ctx)
+ comment := ""
+
+ if cfg.Eth.Genesis != nil {
+ cfg.Eth.Genesis = nil
+ comment += "# Note: this config doesn't contain the genesis block.\n\n"
+ }
+
+ out, err := tomlSettings.Marshal(&cfg)
+ if err != nil {
+ return err
+ }
+ io.WriteString(os.Stdout, comment)
+ os.Stdout.Write(out)
+ return nil
+}
diff --git a/cmd/geth/consolecmd_test.go b/cmd/geth/consolecmd_test.go
index fee8024a9..e5472836c 100644
--- a/cmd/geth/consolecmd_test.go
+++ b/cmd/geth/consolecmd_test.go
@@ -22,14 +22,17 @@ import (
"os"
"path/filepath"
"runtime"
- "sort"
"strconv"
"strings"
"testing"
"time"
"github.com/ethereum/go-ethereum/params"
- "github.com/ethereum/go-ethereum/rpc"
+)
+
+const (
+ ipcAPIs = "admin:1.0 debug:1.0 eth:1.0 miner:1.0 net:1.0 personal:1.0 rpc:1.0 shh:1.0 txpool:1.0 web3:1.0"
+ httpAPIs = "eth:1.0 net:1.0 rpc:1.0 web3:1.0"
)
// Tests that a node embedded within a console can be started up properly and
@@ -49,11 +52,7 @@ func TestConsoleWelcome(t *testing.T) {
geth.setTemplateFunc("gover", runtime.Version)
geth.setTemplateFunc("gethver", func() string { return params.Version })
geth.setTemplateFunc("niltime", func() string { return time.Unix(0, 0).Format(time.RFC1123) })
- geth.setTemplateFunc("apis", func() []string {
- apis := append(strings.Split(rpc.DefaultIPCApis, ","), rpc.MetadataApi)
- sort.Strings(apis)
- return apis
- })
+ geth.setTemplateFunc("apis", func() string { return ipcAPIs })
// Verify the actual welcome message to the required template
geth.expect(`
@@ -63,7 +62,7 @@ instance: Geth/v{{gethver}}/{{goos}}-{{goarch}}/{{gover}}
coinbase: {{.Etherbase}}
at block: 0 ({{niltime}})
datadir: {{.Datadir}}
- modules:{{range apis}} {{.}}:1.0{{end}}
+ modules: {{apis}}
> {{.InputLine "exit"}}
`)
@@ -89,7 +88,7 @@ func TestIPCAttachWelcome(t *testing.T) {
"--etherbase", coinbase, "--shh", "--ipcpath", ipc)
time.Sleep(2 * time.Second) // Simple way to wait for the RPC endpoint to open
- testAttachWelcome(t, geth, "ipc:"+ipc)
+ testAttachWelcome(t, geth, "ipc:"+ipc, ipcAPIs)
geth.interrupt()
geth.expectExit()
@@ -103,7 +102,7 @@ func TestHTTPAttachWelcome(t *testing.T) {
"--etherbase", coinbase, "--rpc", "--rpcport", port)
time.Sleep(2 * time.Second) // Simple way to wait for the RPC endpoint to open
- testAttachWelcome(t, geth, "http://localhost:"+port)
+ testAttachWelcome(t, geth, "http://localhost:"+port, httpAPIs)
geth.interrupt()
geth.expectExit()
@@ -118,13 +117,13 @@ func TestWSAttachWelcome(t *testing.T) {
"--etherbase", coinbase, "--ws", "--wsport", port)
time.Sleep(2 * time.Second) // Simple way to wait for the RPC endpoint to open
- testAttachWelcome(t, geth, "ws://localhost:"+port)
+ testAttachWelcome(t, geth, "ws://localhost:"+port, httpAPIs)
geth.interrupt()
geth.expectExit()
}
-func testAttachWelcome(t *testing.T, geth *testgeth, endpoint string) {
+func testAttachWelcome(t *testing.T, geth *testgeth, endpoint, apis string) {
// Attach to a running geth note and terminate immediately
attach := runGeth(t, "attach", endpoint)
defer attach.expectExit()
@@ -139,16 +138,7 @@ func testAttachWelcome(t *testing.T, geth *testgeth, endpoint string) {
attach.setTemplateFunc("niltime", func() string { return time.Unix(0, 0).Format(time.RFC1123) })
attach.setTemplateFunc("ipc", func() bool { return strings.HasPrefix(endpoint, "ipc") })
attach.setTemplateFunc("datadir", func() string { return geth.Datadir })
- attach.setTemplateFunc("apis", func() []string {
- var apis []string
- if strings.HasPrefix(endpoint, "ipc") {
- apis = append(strings.Split(rpc.DefaultIPCApis, ","), rpc.MetadataApi)
- } else {
- apis = append(strings.Split(rpc.DefaultHTTPApis, ","), rpc.MetadataApi)
- }
- sort.Strings(apis)
- return apis
- })
+ attach.setTemplateFunc("apis", func() string { return apis })
// Verify the actual welcome message to the required template
attach.expect(`
@@ -158,7 +148,7 @@ instance: Geth/v{{gethver}}/{{goos}}-{{goarch}}/{{gover}}
coinbase: {{etherbase}}
at block: 0 ({{niltime}}){{if ipc}}
datadir: {{datadir}}{{end}}
- modules:{{range apis}} {{.}}:1.0{{end}}
+ modules: {{apis}}
> {{.InputLine "exit" }}
`)
diff --git a/cmd/geth/dao_test.go b/cmd/geth/dao_test.go
index f9ce80218..ec7802ada 100644
--- a/cmd/geth/dao_test.go
+++ b/cmd/geth/dao_test.go
@@ -84,27 +84,24 @@ var daoGenesisForkBlock = big.NewInt(314)
// set in the database after various initialization procedures and invocations.
func TestDAOForkBlockNewChain(t *testing.T) {
for i, arg := range []struct {
- testnet bool
genesis string
expectBlock *big.Int
expectVote bool
}{
// Test DAO Default Mainnet
- {false, "", params.MainNetDAOForkBlock, true},
- // test DAO Default Testnet
- {true, "", params.TestNetDAOForkBlock, true},
+ {"", params.MainNetDAOForkBlock, true},
// test DAO Init Old Privnet
- {false, daoOldGenesis, nil, false},
+ {daoOldGenesis, nil, false},
// test DAO Default No Fork Privnet
- {false, daoNoForkGenesis, daoGenesisForkBlock, false},
+ {daoNoForkGenesis, daoGenesisForkBlock, false},
// test DAO Default Pro Fork Privnet
- {false, daoProForkGenesis, daoGenesisForkBlock, true},
+ {daoProForkGenesis, daoGenesisForkBlock, true},
} {
- testDAOForkBlockNewChain(t, i, arg.testnet, arg.genesis, arg.expectBlock, arg.expectVote)
+ testDAOForkBlockNewChain(t, i, arg.genesis, arg.expectBlock, arg.expectVote)
}
}
-func testDAOForkBlockNewChain(t *testing.T, test int, testnet bool, genesis string, expectBlock *big.Int, expectVote bool) {
+func testDAOForkBlockNewChain(t *testing.T, test int, genesis string, expectBlock *big.Int, expectVote bool) {
// Create a temporary data directory to use and inspect later
datadir := tmpdir(t)
defer os.RemoveAll(datadir)
@@ -119,17 +116,11 @@ func testDAOForkBlockNewChain(t *testing.T, test int, testnet bool, genesis stri
} else {
// Force chain initialization
args := []string{"--port", "0", "--maxpeers", "0", "--nodiscover", "--nat", "none", "--ipcdisable", "--datadir", datadir}
- if testnet {
- args = append(args, "--testnet")
- }
geth := runGeth(t, append(args, []string{"--exec", "2+2", "console"}...)...)
geth.cmd.Wait()
}
// Retrieve the DAO config flag from the database
path := filepath.Join(datadir, "geth", "chaindata")
- if testnet && genesis == "" {
- path = filepath.Join(datadir, "testnet", "geth", "chaindata")
- }
db, err := ethdb.NewLDBDatabase(path, 0, 0)
if err != nil {
t.Fatalf("test %d: failed to open test database: %v", test, err)
@@ -137,9 +128,6 @@ func testDAOForkBlockNewChain(t *testing.T, test int, testnet bool, genesis stri
defer db.Close()
genesisHash := common.HexToHash("0xd4e56740f876aef8c010b86a40d5f56745a118d0906a34e69aec8c0db1cb8fa3")
- if testnet {
- genesisHash = common.HexToHash("0x41941023680923e0fe4d74a34bdac8141f2540e3ae90623718e47d66d1ca4a2d")
- }
if genesis != "" {
genesisHash = daoGenesisHash
}
diff --git a/cmd/geth/main.go b/cmd/geth/main.go
index e8aef2bb2..8e434948e 100644
--- a/cmd/geth/main.go
+++ b/cmd/geth/main.go
@@ -18,7 +18,6 @@
package main
import (
- "encoding/hex"
"fmt"
"os"
"runtime"
@@ -29,17 +28,13 @@ import (
"github.com/ethereum/go-ethereum/accounts/keystore"
"github.com/ethereum/go-ethereum/cmd/utils"
"github.com/ethereum/go-ethereum/common"
- "github.com/ethereum/go-ethereum/common/hexutil"
"github.com/ethereum/go-ethereum/console"
- "github.com/ethereum/go-ethereum/contracts/release"
"github.com/ethereum/go-ethereum/eth"
"github.com/ethereum/go-ethereum/ethclient"
"github.com/ethereum/go-ethereum/internal/debug"
"github.com/ethereum/go-ethereum/log"
"github.com/ethereum/go-ethereum/metrics"
"github.com/ethereum/go-ethereum/node"
- "github.com/ethereum/go-ethereum/params"
- "github.com/ethereum/go-ethereum/rlp"
"gopkg.in/urfave/cli.v1"
)
@@ -82,6 +77,8 @@ func init() {
versionCommand,
bugCommand,
licenseCommand,
+ // See config.go
+ dumpConfigCommand,
}
app.Flags = []cli.Flag{
@@ -99,6 +96,7 @@ func init() {
utils.EthashDatasetsOnDiskFlag,
utils.FastSyncFlag,
utils.LightModeFlag,
+ utils.SyncModeFlag,
utils.LightServFlag,
utils.LightPeersFlag,
utils.LightKDFFlag,
@@ -129,16 +127,12 @@ func init() {
utils.WSApiFlag,
utils.WSAllowedOriginsFlag,
utils.IPCDisabledFlag,
- utils.IPCApiFlag,
utils.IPCPathFlag,
utils.ExecFlag,
utils.PreloadJSFlag,
utils.WhisperEnabledFlag,
utils.DevModeFlag,
utils.TestNetFlag,
- utils.VMForceJitFlag,
- utils.VMJitCacheFlag,
- utils.VMEnableJitFlag,
utils.VMEnableDebugFlag,
utils.NetworkIdFlag,
utils.RPCCORSDomainFlag,
@@ -150,6 +144,7 @@ func init() {
utils.GpoBlocksFlag,
utils.GpoPercentileFlag,
utils.ExtraDataFlag,
+ configFileFlag,
}
app.Flags = append(app.Flags, debug.Flags...)
@@ -189,52 +184,6 @@ func geth(ctx *cli.Context) error {
return nil
}
-func makeFullNode(ctx *cli.Context) *node.Node {
- // Create the default extradata and construct the base node
- var clientInfo = struct {
- Version uint
- Name string
- GoVersion string
- Os string
- }{uint(params.VersionMajor<<16 | params.VersionMinor<<8 | params.VersionPatch), clientIdentifier, runtime.Version(), runtime.GOOS}
- extra, err := rlp.EncodeToBytes(clientInfo)
- if err != nil {
- log.Warn("Failed to set canonical miner information", "err", err)
- }
- if uint64(len(extra)) > params.MaximumExtraDataSize {
- log.Warn("Miner extra data exceed limit", "extra", hexutil.Bytes(extra), "limit", params.MaximumExtraDataSize)
- extra = nil
- }
- stack := utils.MakeNode(ctx, clientIdentifier, gitCommit)
- utils.RegisterEthService(ctx, stack, extra)
-
- // Whisper must be explicitly enabled, but is auto-enabled in --dev mode.
- shhEnabled := ctx.GlobalBool(utils.WhisperEnabledFlag.Name)
- shhAutoEnabled := !ctx.GlobalIsSet(utils.WhisperEnabledFlag.Name) && ctx.GlobalIsSet(utils.DevModeFlag.Name)
- if shhEnabled || shhAutoEnabled {
- utils.RegisterShhService(stack)
- }
- // Add the Ethereum Stats daemon if requested
- if url := ctx.GlobalString(utils.EthStatsURLFlag.Name); url != "" {
- utils.RegisterEthStatsService(stack, url)
- }
- // Add the release oracle service so it boots along with node.
- if err := stack.Register(func(ctx *node.ServiceContext) (node.Service, error) {
- config := release.Config{
- Oracle: relOracle,
- Major: uint32(params.VersionMajor),
- Minor: uint32(params.VersionMinor),
- Patch: uint32(params.VersionPatch),
- }
- commit, _ := hex.DecodeString(gitCommit)
- copy(config.Commit[:], commit)
- return release.NewReleaseService(ctx, config)
- }); err != nil {
- utils.Fatalf("Failed to register the Geth release oracle service: %v", err)
- }
- return stack
-}
-
// startNode boots up the system node and all registered protocols, after which
// it unlocks any requested accounts, and starts the RPC/IPC interfaces and the
// miner.
diff --git a/cmd/geth/usage.go b/cmd/geth/usage.go
index 491a4eb98..334d017d9 100644
--- a/cmd/geth/usage.go
+++ b/cmd/geth/usage.go
@@ -115,7 +115,6 @@ var AppHelpFlagGroups = []flagGroup{
utils.WSApiFlag,
utils.WSAllowedOriginsFlag,
utils.IPCDisabledFlag,
- utils.IPCApiFlag,
utils.IPCPathFlag,
utils.RPCCORSDomainFlag,
utils.JSpathFlag,
@@ -158,9 +157,6 @@ var AppHelpFlagGroups = []flagGroup{
{
Name: "VIRTUAL MACHINE",
Flags: []cli.Flag{
- utils.VMEnableJitFlag,
- utils.VMForceJitFlag,
- utils.VMJitCacheFlag,
utils.VMEnableDebugFlag,
},
},
diff --git a/cmd/puppeth/module_dashboard.go b/cmd/puppeth/module_dashboard.go
index cf8dcb1e2..17f119111 100644
--- a/cmd/puppeth/module_dashboard.go
+++ b/cmd/puppeth/module_dashboard.go
@@ -32,95 +32,95 @@ import (
var dashboardContent = `
<!DOCTYPE html>
<html lang="en">
- <head>
- <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
- <!-- Meta, title, CSS, favicons, etc. -->
- <meta charset="utf-8">
- <meta http-equiv="X-UA-Compatible" content="IE=edge">
- <meta name="viewport" content="width=device-width, initial-scale=1">
-
- <title>{{.NetworkTitle}}: Ethereum Testnet</title>
-
- <link href="https://cdnjs.cloudflare.com/ajax/libs/twitter-bootstrap/3.3.7/css/bootstrap.min.css" rel="stylesheet">
- <link href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/4.7.0/css/font-awesome.min.css" rel="stylesheet">
- <link href="https://cdnjs.cloudflare.com/ajax/libs/gentelella/1.3.0/css/custom.min.css" rel="stylesheet">
- <style>
- .vertical-center {
- min-height: 100%;
- min-height: 95vh;
- display: flex;
- align-items: center;
- }
- .nav.side-menu li a {
- font-size: 18px;
- }
- .nav-sm .nav.side-menu li a {
- font-size: 10px;
- }
- pre{
- white-space: pre-wrap;
- }
- </style>
- </head>
-
- <body class="nav-sm" style="overflow-x: hidden">
- <div class="container body">
- <div class="main_container">
- <div class="col-md-3 left_col">
- <div class="left_col scroll-view">
- <div class="navbar nav_title" style="border: 0; margin-top: 8px;">
- <a class="site_title"><i class="fa fa-globe" style="margin-left: 6px"></i> <span>{{.NetworkTitle}} Testnet</span></a>
- </div>
- <div class="clearfix"></div>
- <br />
- <div id="sidebar-menu" class="main_menu_side hidden-print main_menu">
- <div class="menu_section">
- <ul class="nav side-menu">
+ <head>
+ <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
+ <!-- Meta, title, CSS, favicons, etc. -->
+ <meta charset="utf-8">
+ <meta http-equiv="X-UA-Compatible" content="IE=edge">
+ <meta name="viewport" content="width=device-width, initial-scale=1">
+
+ <title>{{.NetworkTitle}}: Ethereum Testnet</title>
+
+ <link href="https://cdnjs.cloudflare.com/ajax/libs/twitter-bootstrap/3.3.7/css/bootstrap.min.css" rel="stylesheet">
+ <link href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/4.7.0/css/font-awesome.min.css" rel="stylesheet">
+ <link href="https://cdnjs.cloudflare.com/ajax/libs/gentelella/1.3.0/css/custom.min.css" rel="stylesheet">
+ <style>
+ .vertical-center {
+ min-height: 100%;
+ min-height: 95vh;
+ display: flex;
+ align-items: center;
+ }
+ .nav.side-menu li a {
+ font-size: 18px;
+ }
+ .nav-sm .nav.side-menu li a {
+ font-size: 10px;
+ }
+ pre{
+ white-space: pre-wrap;
+ }
+ </style>
+ </head>
+
+ <body class="nav-sm" style="overflow-x: hidden">
+ <div class="container body">
+ <div class="main_container">
+ <div class="col-md-3 left_col">
+ <div class="left_col scroll-view">
+ <div class="navbar nav_title" style="border: 0; margin-top: 8px;">
+ <a class="site_title"><i class="fa fa-globe" style="margin-left: 6px"></i> <span>{{.NetworkTitle}} Testnet</span></a>
+ </div>
+ <div class="clearfix"></div>
+ <br />
+ <div id="sidebar-menu" class="main_menu_side hidden-print main_menu">
+ <div class="menu_section">
+ <ul class="nav side-menu">
{{if .EthstatsPage}}<li><a onclick="load('//{{.EthstatsPage}}')"><i class="fa fa-tachometer"></i> Network Stats</a></li>{{end}}
- {{if .ExplorerPage}}<li><a onclick="load('//{{.ExplorerPage}}')"><i class="fa fa-database"></i> Block Explorer</a></li>{{end}}
- {{if .WalletPage}}<li><a onclick="load('//{{.WalletPage}}')"><i class="fa fa-address-book-o"></i> Browser Wallet</a></li>{{end}}
- {{if .FaucetPage}}<li><a onclick="load('//{{.FaucetPage}}')"><i class="fa fa-bath"></i> Crypto Faucet</a></li>{{end}}
- <li id="connect"><a><i class="fa fa-plug"></i> Connect Yourself</a>
+ {{if .ExplorerPage}}<li><a onclick="load('//{{.ExplorerPage}}')"><i class="fa fa-database"></i> Block Explorer</a></li>{{end}}
+ {{if .WalletPage}}<li><a onclick="load('//{{.WalletPage}}')"><i class="fa fa-address-book-o"></i> Browser Wallet</a></li>{{end}}
+ {{if .FaucetPage}}<li><a onclick="load('//{{.FaucetPage}}')"><i class="fa fa-bath"></i> Crypto Faucet</a></li>{{end}}
+ <li id="connect"><a><i class="fa fa-plug"></i> Connect Yourself</a>
<ul id="connect_list" class="nav child_menu">
<li><a onclick="$('#connect').removeClass('active'); $('#connect_list').toggle(); load('#connect-go-ethereum-geth')">Go Ethereum: Geth</a></li>
<li><a onclick="$('#connect').removeClass('active'); $('#connect_list').toggle(); load('#connect-go-ethereum-mist')">Go Ethereum: Wallet & Mist</a></li>
<li><a onclick="$('#connect').removeClass('active'); $('#connect_list').toggle(); load('#connect-go-ethereum-mobile')">Go Ethereum: Android & iOS</a></li>
</ul>
</li>
- <li><a onclick="load('#about')"><i class="fa fa-heartbeat"></i> About Puppeth</a></li>
- </ul>
- </div>
- </div>
- </div>
- </div>
- <div class="right_col" role="main" style="padding: 0">
+ <li><a onclick="load('#about')"><i class="fa fa-heartbeat"></i> About Puppeth</a></li>
+ </ul>
+ </div>
+ </div>
+ </div>
+ </div>
+ <div class="right_col" role="main" style="padding: 0">
<div id="connect-go-ethereum-geth" hidden style="padding: 16px;">
- <div class="page-title">
- <div class="title_left">
- <h3>Connect Yourself &ndash; Go Ethereum: Geth</h3>
- </div>
- </div>
- <div class="clearfix"></div>
+ <div class="page-title">
+ <div class="title_left">
+ <h3>Connect Yourself &ndash; Go Ethereum: Geth</h3>
+ </div>
+ </div>
+ <div class="clearfix"></div>
<div class="row">
- <div class="col-md-6">
- <div class="x_panel">
- <div class="x_title">
- <h2><i class="fa fa-archive" aria-hidden="true"></i> Archive node <small>Retains all historical data</small></h2>
- <div class="clearfix"></div>
- </div>
- <div class="x_content">
+ <div class="col-md-6">
+ <div class="x_panel">
+ <div class="x_title">
+ <h2><i class="fa fa-archive" aria-hidden="true"></i> Archive node <small>Retains all historical data</small></h2>
+ <div class="clearfix"></div>
+ </div>
+ <div class="x_content">
<p>An archive node synchronizes the blockchain by downloading the full chain from the genesis block to the current head block, executing all the transactions contained within. As the node crunches through the transactions, all past historical state is stored on disk, and can be queried for each and every block.</p>
<p>Initial processing required to execute all transactions may require non-negligible time and disk capacity required to store all past state may be non-insignificant. High end machines with SSD storage, modern CPUs and 8GB+ RAM are recommended.</p>
<br/>
<p>To run an archive node, download <a href="/{{.GethGenesis}}"><code>{{.GethGenesis}}</code></a> and start Geth with:
- <pre>geth --datadir=$HOME/.{{.Network}} init {{.GethGenesis}}</pre>
- <pre>geth --networkid={{.NetworkID}} --datadir=$HOME/.{{.Network}} --cache=1024{{if .Ethstats}} --ethstats='{{.Ethstats}}'{{end}} --bootnodes={{.BootnodesFullFlat}}</pre>
+ <pre>geth --datadir=$HOME/.{{.Network}} init {{.GethGenesis}}</pre>
+ <pre>geth --networkid={{.NetworkID}} --datadir=$HOME/.{{.Network}} --cache=1024 --syncmode=full{{if .Ethstats}} --ethstats='{{.Ethstats}}'{{end}} --bootnodes={{.BootnodesFullFlat}}</pre>
</p>
<br/>
<p>You can download Geth from <a href="https://geth.ethereum.org/downloads/" target="about:blank">https://geth.ethereum.org/downloads/</a>.</p>
- </div>
- </div>
- </div>
+ </div>
+ </div>
+ </div>
<div class="col-md-6">
<div class="x_panel">
<div class="x_title">
@@ -132,8 +132,8 @@ var dashboardContent = `
<p>Initial processing required to synchronize is more bandwidth intensive, but is light on the CPU and has significantly reduced disk requirements. Mid range machines with HDD storage, decent CPUs and 4GB+ RAM should be enough.</p>
<br/>
<p>To run a full node, download <a href="/{{.GethGenesis}}"><code>{{.GethGenesis}}</code></a> and start Geth with:
- <pre>geth --datadir=$HOME/.{{.Network}} init {{.GethGenesis}}</pre>
- <pre>geth --networkid={{.NetworkID}} --datadir=$HOME/.{{.Network}} --cache=512 --fast{{if .Ethstats}} --ethstats='{{.Ethstats}}'{{end}} --bootnodes={{.BootnodesFullFlat}}</pre>
+ <pre>geth --datadir=$HOME/.{{.Network}} init {{.GethGenesis}}</pre>
+ <pre>geth --networkid={{.NetworkID}} --datadir=$HOME/.{{.Network}} --cache=512{{if .Ethstats}} --ethstats='{{.Ethstats}}'{{end}} --bootnodes={{.BootnodesFullFlat}}</pre>
</p>
<br/>
<p>You can download Geth from <a href="https://geth.ethereum.org/downloads/" target="about:blank">https://geth.ethereum.org/downloads/</a>.</p>
@@ -150,12 +150,12 @@ var dashboardContent = `
<div class="clearfix"></div>
</div>
<div class="x_content">
- <p>A light node synchronizes the blockchain by downloading and verifying only the chain of headers from the genesis block to the current head, without executing any transactions or retrieving any associated state. As no state is available locally, any interaction with the blockchain relies on on-demand data retrievals from remote nodes.</p>
+ <p>A light node synchronizes the blockchain by downloading and verifying only the chain of headers from the genesis block to the current head, without executing any transactions or retrieving any associated state. As no state is available locally, any interaction with the blockchain relies on on-demand data retrievals from remote nodes.</p>
<p>Initial processing required to synchronize is light, as it only verifies the validity of the headers; similarly required disk capacity is small, tallying around 500 bytes per header. Low end machines with arbitrary storage, weak CPUs and 512MB+ RAM should cope well.</p>
<br/>
<p>To run a light node, download <a href="/{{.GethGenesis}}"><code>{{.GethGenesis}}</code></a> and start Geth with:
- <pre>geth --datadir=$HOME/.{{.Network}} --light init {{.GethGenesis}}</pre>
- <pre>geth --networkid={{.NetworkID}} --datadir=$HOME/.{{.Network}} --light{{if .Ethstats}} --ethstats='{{.Ethstats}}'{{end}} --bootnodes={{.BootnodesLightFlat}}</pre>
+ <pre>geth --datadir=$HOME/.{{.Network}} --light init {{.GethGenesis}}</pre>
+ <pre>geth --networkid={{.NetworkID}} --datadir=$HOME/.{{.Network}} --syncmode=light{{if .Ethstats}} --ethstats='{{.Ethstats}}'{{end}} --bootnodes={{.BootnodesLightFlat}}</pre>
</p>
<br/>
<p>You can download Geth from <a href="https://geth.ethereum.org/downloads/" target="about:blank">https://geth.ethereum.org/downloads/</a>.</p>
@@ -169,12 +169,12 @@ var dashboardContent = `
<div class="clearfix"></div>
</div>
<div class="x_content">
- <p>An embedded node is a variation of the light node with configuration parameters tuned towards low memory footprint. As such, it may sacrifice processing and disk IO performance to conserve memory. It should be considered an <strong>experimental</strong> direction for now without hard guarantees or bounds on the resources used.</p>
+ <p>An embedded node is a variation of the light node with configuration parameters tuned towards low memory footprint. As such, it may sacrifice processing and disk IO performance to conserve memory. It should be considered an <strong>experimental</strong> direction for now without hard guarantees or bounds on the resources used.</p>
<p>Initial processing required to synchronize is light, as it only verifies the validity of the headers; similarly required disk capacity is small, tallying around 500 bytes per header. Embedded machines with arbitrary storage, low power CPUs and 128MB+ RAM may work.</p>
<br/>
<p>To run an embedded node, download <a href="/{{.GethGenesis}}"><code>{{.GethGenesis}}</code></a> and start Geth with:
- <pre>geth --datadir=$HOME/.{{.Network}} --light init {{.GethGenesis}}</pre>
- <pre>geth --networkid={{.NetworkID}} --datadir=$HOME/.{{.Network}} --cache=32 --light{{if .Ethstats}} --ethstats='{{.Ethstats}}'{{end}} --bootnodes={{.BootnodesLightFlat}}</pre>
+ <pre>geth --datadir=$HOME/.{{.Network}} --light init {{.GethGenesis}}</pre>
+ <pre>geth --networkid={{.NetworkID}} --datadir=$HOME/.{{.Network}} --cache=32 --syncmode=light{{if .Ethstats}} --ethstats='{{.Ethstats}}'{{end}} --bootnodes={{.BootnodesLightFlat}}</pre>
</p>
<br/>
<p>You can download Geth from <a href="https://geth.ethereum.org/downloads/" target="about:blank">https://geth.ethereum.org/downloads/</a>.</p>
@@ -182,81 +182,81 @@ var dashboardContent = `
</div>
</div>
</div>
- </div>
- <div id="connect-go-ethereum-mist" hidden style="padding: 16px;">
- <div class="page-title">
- <div class="title_left">
- <h3>Connect Yourself &ndash; Go Ethereum: Wallet &amp; Mist</h3>
- </div>
- </div>
- <div class="clearfix"></div>
- <div class="row">
- <div class="col-md-6">
- <div class="x_panel">
- <div class="x_title">
- <h2><i class="fa fa-credit-card" aria-hidden="true"></i> Desktop wallet <small>Interacts with accounts and contracts</small></h2>
- <div class="clearfix"></div>
- </div>
- <div class="x_content">
- <p>The Ethereum Wallet is an <a href="https://electron.atom.io/" target="about:blank">Electron</a> based desktop application to manage your Ethereum accounts and funds. Beside the usual account life-cycle operations you would expect to perform, the wallet also provides a means to send transactions from your accounts and to interact with smart contracts deployed on the network.</p>
- <p>Under the hood the wallet is backed by a go-ethereum full node, meaning that a mid range machine is assumed. Similarly, synchronization is based on <strong>fast-sync</strong>, which will download all blockchain data from the network and make it available to the wallet. Light nodes cannot currently fully back the wallet, but it's a target actively pursued.</p>
- <br/>
- <p>To connect with the Ethereum Wallet, you'll need to initialize your private network first via Geth as the wallet does not currently support calling Geth directly. To initialize your local chain, download <a href="/{{.GethGenesis}}"><code>{{.GethGenesis}}</code></a> and run:
- <pre>geth --datadir=$HOME/.{{.Network}} init {{.GethGenesis}}</pre>
- </p>
- <p>With your local chain initialized, you can start the Ethereum Wallet:
- <pre>ethereumwallet --rpc $HOME/.{{.Network}}/geth.ipc --node-networkid={{.NetworkID}} --node-datadir=$HOME/.{{.Network}}{{if .Ethstats}} --node-ethstats='{{.Ethstats}}'{{end}} --node-bootnodes={{.BootnodesFullFlat}}</pre>
- <p>
- <br/>
- <p>You can download the Ethereum Wallet from <a href="https://github.com/ethereum/mist/releases" target="about:blank">https://github.com/ethereum/mist/releases</a>.</p>
- </div>
- </div>
- </div>
- <div class="col-md-6">
- <div class="x_panel">
- <div class="x_title">
- <h2><i class="fa fa-picture-o" aria-hidden="true"></i> Mist browser <small>Interacts with third party DApps</small></h2>
- <div class="clearfix"></div>
- </div>
- <div class="x_content">
- <p>The Mist browser is an <a href="https://electron.atom.io/" target="about:blank">Electron</a> based desktop application to load and interact with Ethereum enabled third party web DApps. Beside all the functionality provided by the Ethereum Wallet, Mist is an extended web-browser where loaded pages have access to the Ethereum network via a web3.js provider, and may also interact with users' own accounts (given proper authorization and confirmation of course).</p>
- <p>Under the hood the browser is backed by a go-ethereum full node, meaning that a mid range machine is assumed. Similarly, synchronization is based on <strong>fast-sync</strong>, which will download all blockchain data from the network and make it available to the wallet. Light nodes cannot currently fully back the wallet, but it's a target actively pursued.</p>
- <br/>
- <p>To connect with the Mist browser, you'll need to initialize your private network first via Geth as Mist does not currently support calling Geth directly. To initialize your local chain, download <a href="/{{.GethGenesis}}"><code>{{.GethGenesis}}</code></a> and run:
- <pre>geth --datadir=$HOME/.{{.Network}} init {{.GethGenesis}}</pre>
- </p>
- <p>With your local chain initialized, you can start Mist:
- <pre>mist --rpc $HOME/.{{.Network}}/geth.ipc --node-networkid={{.NetworkID}} --node-datadir=$HOME/.{{.Network}}{{if .Ethstats}} --node-ethstats='{{.Ethstats}}'{{end}} --node-bootnodes={{.BootnodesFullFlat}}</pre>
- <p>
- <br/>
- <p>You can download the Mist browser from <a href="https://github.com/ethereum/mist/releases" target="about:blank">https://github.com/ethereum/mist/releases</a>.</p>
- </div>
- </div>
- </div>
- </div>
- </div>
- <div id="connect-go-ethereum-mobile" hidden style="padding: 16px;">
- <div class="page-title">
- <div class="title_left">
- <h3>Connect Yourself &ndash; Go Ethereum: Android &amp; iOS</h3>
- </div>
- </div>
- <div class="clearfix"></div>
- <div class="row">
- <div class="col-md-6">
- <div class="x_panel">
- <div class="x_title">
- <h2><i class="fa fa-android" aria-hidden="true"></i> Android devices <small>Accesses Ethereum via Java</small></h2>
- <div class="clearfix"></div>
- </div>
- <div class="x_content">
- <p>Starting with the 1.5 release of go-ethereum, we've transitioned away from shipping only full blown Ethereum clients and started focusing on releasing the code as reusable packages initially for Go projects, then later for Java based Android projects too. Mobile support is still evolving, hence is bound to change often and hard, but the Ethereum network can nonetheless be accessed from Android too.</p>
- <p>Under the hood the Android library is backed by a go-ethereum light node, meaning that given a not-too-old Android device, you should be able to join the network without significant issues. Certain functionality is not yet available and rough edges are bound to appear here and there, please report issues if you find any.</p>
- <br/>
- <p>The stable Android archives are distributed via Maven Central, and the develop snapshots via the Sonatype repositories. Before proceeding, please ensure you have a recent version configured in your Android project. You can find details in <a href="https://github.com/ethereum/go-ethereum/wiki/Mobile:-Introduction#android-archive" target="about:blank">Mobile: Introduction &ndash; Android archive</a>.
- <p>Before connecting to the Ethereum network, download the <a href="/{{.GethGenesis}}"><code>{{.GethGenesis}}</code></a> genesis json file and either store it in your Android project as a resource file you can access, or save it as a string in a variable. You're going to need to to initialize your client.</p>
- <p>Inside your Java code you can now import the geth archive and connect to Ethereum:
- <pre>import org.ethereum.geth.*;</pre>
+ </div>
+ <div id="connect-go-ethereum-mist" hidden style="padding: 16px;">
+ <div class="page-title">
+ <div class="title_left">
+ <h3>Connect Yourself &ndash; Go Ethereum: Wallet &amp; Mist</h3>
+ </div>
+ </div>
+ <div class="clearfix"></div>
+ <div class="row">
+ <div class="col-md-6">
+ <div class="x_panel">
+ <div class="x_title">
+ <h2><i class="fa fa-credit-card" aria-hidden="true"></i> Desktop wallet <small>Interacts with accounts and contracts</small></h2>
+ <div class="clearfix"></div>
+ </div>
+ <div class="x_content">
+ <p>The Ethereum Wallet is an <a href="https://electron.atom.io/" target="about:blank">Electron</a> based desktop application to manage your Ethereum accounts and funds. Beside the usual account life-cycle operations you would expect to perform, the wallet also provides a means to send transactions from your accounts and to interact with smart contracts deployed on the network.</p>
+ <p>Under the hood the wallet is backed by a go-ethereum full node, meaning that a mid range machine is assumed. Similarly, synchronization is based on <strong>fast-sync</strong>, which will download all blockchain data from the network and make it available to the wallet. Light nodes cannot currently fully back the wallet, but it's a target actively pursued.</p>
+ <br/>
+ <p>To connect with the Ethereum Wallet, you'll need to initialize your private network first via Geth as the wallet does not currently support calling Geth directly. To initialize your local chain, download <a href="/{{.GethGenesis}}"><code>{{.GethGenesis}}</code></a> and run:
+ <pre>geth --datadir=$HOME/.{{.Network}} init {{.GethGenesis}}</pre>
+ </p>
+ <p>With your local chain initialized, you can start the Ethereum Wallet:
+ <pre>ethereumwallet --rpc $HOME/.{{.Network}}/geth.ipc --node-networkid={{.NetworkID}} --node-datadir=$HOME/.{{.Network}}{{if .Ethstats}} --node-ethstats='{{.Ethstats}}'{{end}} --node-bootnodes={{.BootnodesFullFlat}}</pre>
+ <p>
+ <br/>
+ <p>You can download the Ethereum Wallet from <a href="https://github.com/ethereum/mist/releases" target="about:blank">https://github.com/ethereum/mist/releases</a>.</p>
+ </div>
+ </div>
+ </div>
+ <div class="col-md-6">
+ <div class="x_panel">
+ <div class="x_title">
+ <h2><i class="fa fa-picture-o" aria-hidden="true"></i> Mist browser <small>Interacts with third party DApps</small></h2>
+ <div class="clearfix"></div>
+ </div>
+ <div class="x_content">
+ <p>The Mist browser is an <a href="https://electron.atom.io/" target="about:blank">Electron</a> based desktop application to load and interact with Ethereum enabled third party web DApps. Beside all the functionality provided by the Ethereum Wallet, Mist is an extended web-browser where loaded pages have access to the Ethereum network via a web3.js provider, and may also interact with users' own accounts (given proper authorization and confirmation of course).</p>
+ <p>Under the hood the browser is backed by a go-ethereum full node, meaning that a mid range machine is assumed. Similarly, synchronization is based on <strong>fast-sync</strong>, which will download all blockchain data from the network and make it available to the wallet. Light nodes cannot currently fully back the wallet, but it's a target actively pursued.</p>
+ <br/>
+ <p>To connect with the Mist browser, you'll need to initialize your private network first via Geth as Mist does not currently support calling Geth directly. To initialize your local chain, download <a href="/{{.GethGenesis}}"><code>{{.GethGenesis}}</code></a> and run:
+ <pre>geth --datadir=$HOME/.{{.Network}} init {{.GethGenesis}}</pre>
+ </p>
+ <p>With your local chain initialized, you can start Mist:
+ <pre>mist --rpc $HOME/.{{.Network}}/geth.ipc --node-networkid={{.NetworkID}} --node-datadir=$HOME/.{{.Network}}{{if .Ethstats}} --node-ethstats='{{.Ethstats}}'{{end}} --node-bootnodes={{.BootnodesFullFlat}}</pre>
+ <p>
+ <br/>
+ <p>You can download the Mist browser from <a href="https://github.com/ethereum/mist/releases" target="about:blank">https://github.com/ethereum/mist/releases</a>.</p>
+ </div>
+ </div>
+ </div>
+ </div>
+ </div>
+ <div id="connect-go-ethereum-mobile" hidden style="padding: 16px;">
+ <div class="page-title">
+ <div class="title_left">
+ <h3>Connect Yourself &ndash; Go Ethereum: Android &amp; iOS</h3>
+ </div>
+ </div>
+ <div class="clearfix"></div>
+ <div class="row">
+ <div class="col-md-6">
+ <div class="x_panel">
+ <div class="x_title">
+ <h2><i class="fa fa-android" aria-hidden="true"></i> Android devices <small>Accesses Ethereum via Java</small></h2>
+ <div class="clearfix"></div>
+ </div>
+ <div class="x_content">
+ <p>Starting with the 1.5 release of go-ethereum, we've transitioned away from shipping only full blown Ethereum clients and started focusing on releasing the code as reusable packages initially for Go projects, then later for Java based Android projects too. Mobile support is still evolving, hence is bound to change often and hard, but the Ethereum network can nonetheless be accessed from Android too.</p>
+ <p>Under the hood the Android library is backed by a go-ethereum light node, meaning that given a not-too-old Android device, you should be able to join the network without significant issues. Certain functionality is not yet available and rough edges are bound to appear here and there, please report issues if you find any.</p>
+ <br/>
+ <p>The stable Android archives are distributed via Maven Central, and the develop snapshots via the Sonatype repositories. Before proceeding, please ensure you have a recent version configured in your Android project. You can find details in <a href="https://github.com/ethereum/go-ethereum/wiki/Mobile:-Introduction#android-archive" target="about:blank">Mobile: Introduction &ndash; Android archive</a>.
+ <p>Before connecting to the Ethereum network, download the <a href="/{{.GethGenesis}}"><code>{{.GethGenesis}}</code></a> genesis json file and either store it in your Android project as a resource file you can access, or save it as a string in a variable. You're going to need to to initialize your client.</p>
+ <p>Inside your Java code you can now import the geth archive and connect to Ethereum:
+ <pre>import org.ethereum.geth.*;</pre>
<pre>
Enodes bootnodes = new Enodes();{{range .BootnodesLight}}
bootnodes.append(new Enode("{{.}}"));{{end}}
@@ -270,24 +270,24 @@ config.setEthereumNetStats("{{.Ethstats}}");{{end}}
Node node = new Node(getFilesDir() + "/.{{.Network}}", config);
node.start();
</pre>
- <p>
- </div>
- </div>
- </div>
- <div class="col-md-6">
- <div class="x_panel">
- <div class="x_title">
- <h2><i class="fa fa-apple" aria-hidden="true"></i> iOS devices <small>Accesses Ethereum via ObjC/Swift</small></h2>
- <div class="clearfix"></div>
- </div>
- <div class="x_content">
- <p>Starting with the 1.5 release of go-ethereum, we've transitioned away from shipping only full blown Ethereum clients and started focusing on releasing the code as reusable packages initially for Go projects, then later for ObjC/Swift based iOS projects too. Mobile support is still evolving, hence is bound to change often and hard, but the Ethereum network can nonetheless be accessed from iOS too.</p>
- <p>Under the hood the iOS library is backed by a go-ethereum light node, meaning that given a not-too-old Apple device, you should be able to join the network without significant issues. Certain functionality is not yet available and rough edges are bound to appear here and there, please report issues if you find any.</p>
- <br/>
- <p>Both stable and develop builds of the iOS framework are available via CocoaPods. Before proceeding, please ensure you have a recent version configured in your iOS project. You can find details in <a href="https://github.com/ethereum/go-ethereum/wiki/Mobile:-Introduction#ios-framework" target="about:blank">Mobile: Introduction &ndash; iOS framework</a>.
- <p>Before connecting to the Ethereum network, download the <a href="/{{.GethGenesis}}"><code>{{.GethGenesis}}</code></a> genesis json file and either store it in your iOS project as a resource file you can access, or save it as a string in a variable. You're going to need to to initialize your client.</p>
- <p>Inside your Swift code you can now import the geth framework and connect to Ethereum (ObjC should be analogous):
- <pre>import Geth</pre>
+ <p>
+ </div>
+ </div>
+ </div>
+ <div class="col-md-6">
+ <div class="x_panel">
+ <div class="x_title">
+ <h2><i class="fa fa-apple" aria-hidden="true"></i> iOS devices <small>Accesses Ethereum via ObjC/Swift</small></h2>
+ <div class="clearfix"></div>
+ </div>
+ <div class="x_content">
+ <p>Starting with the 1.5 release of go-ethereum, we've transitioned away from shipping only full blown Ethereum clients and started focusing on releasing the code as reusable packages initially for Go projects, then later for ObjC/Swift based iOS projects too. Mobile support is still evolving, hence is bound to change often and hard, but the Ethereum network can nonetheless be accessed from iOS too.</p>
+ <p>Under the hood the iOS library is backed by a go-ethereum light node, meaning that given a not-too-old Apple device, you should be able to join the network without significant issues. Certain functionality is not yet available and rough edges are bound to appear here and there, please report issues if you find any.</p>
+ <br/>
+ <p>Both stable and develop builds of the iOS framework are available via CocoaPods. Before proceeding, please ensure you have a recent version configured in your iOS project. You can find details in <a href="https://github.com/ethereum/go-ethereum/wiki/Mobile:-Introduction#ios-framework" target="about:blank">Mobile: Introduction &ndash; iOS framework</a>.
+ <p>Before connecting to the Ethereum network, download the <a href="/{{.GethGenesis}}"><code>{{.GethGenesis}}</code></a> genesis json file and either store it in your iOS project as a resource file you can access, or save it as a string in a variable. You're going to need to to initialize your client.</p>
+ <p>Inside your Swift code you can now import the geth framework and connect to Ethereum (ObjC should be analogous):
+ <pre>import Geth</pre>
<pre>
var error: NSError?
@@ -304,86 +304,86 @@ let datadir = NSSearchPathForDirectoriesInDomains(.documentDirectory, .userDomai
let node = GethNewNode(datadir + "/.{{.Network}}", config, &error);
try! node?.start();
</pre>
- <p>
- </div>
- </div>
- </div>
- </div>
- </div>
- <div id="about" hidden>
- <div class="row vertical-center">
- <div style="margin: 0 auto;">
- <div class="x_panel">
- <div class="x_title">
- <h3>Puppeth &ndash; Your Ethereum private network manager</h3>
- <div class="clearfix"></div>
- </div>
- <div style="display: inline-block; vertical-align: bottom; width: 623px; margin-top: 16px;">
- <p>Puppeth is a tool to aid you in creating a new Ethereum network down to the genesis block, bootnodes, signers, ethstats server, crypto faucet, wallet browsers, block explorer, dashboard and more; without the hassle that it would normally entail to manually configure all these services one by one.</p>
- <p>Puppeth uses ssh to dial in to remote servers, and builds its network components out of docker containers using docker-compose. The user is guided through the process via a command line wizard that does the heavy lifting and topology configuration automatically behind the scenes.</p>
- <br/>
- <p>Puppeth is distributed as part of the <a href="https://geth.ethereum.org/downloads/" target="about:blank">Geth &amp; Tools</a> bundles, but can also be installed separately via:<pre>go get github.com/ethereum/go-ethereum/cmd/puppeth</pre></p>
- <br/>
- <p><em>Copyright 2017. The go-ethereum Authors.</em></p>
- </div>
- <div style="display: inline-block; vertical-align: bottom; width: 217px;">
- <img src="puppeth.png" style="height: 256px; margin: 16px 16px 16px 16px"></img>
- </div>
- </div>
- </div>
- </div>
- </div>
+ <p>
+ </div>
+ </div>
+ </div>
+ </div>
+ </div>
+ <div id="about" hidden>
+ <div class="row vertical-center">
+ <div style="margin: 0 auto;">
+ <div class="x_panel">
+ <div class="x_title">
+ <h3>Puppeth &ndash; Your Ethereum private network manager</h3>
+ <div class="clearfix"></div>
+ </div>
+ <div style="display: inline-block; vertical-align: bottom; width: 623px; margin-top: 16px;">
+ <p>Puppeth is a tool to aid you in creating a new Ethereum network down to the genesis block, bootnodes, signers, ethstats server, crypto faucet, wallet browsers, block explorer, dashboard and more; without the hassle that it would normally entail to manually configure all these services one by one.</p>
+ <p>Puppeth uses ssh to dial in to remote servers, and builds its network components out of docker containers using docker-compose. The user is guided through the process via a command line wizard that does the heavy lifting and topology configuration automatically behind the scenes.</p>
+ <br/>
+ <p>Puppeth is distributed as part of the <a href="https://geth.ethereum.org/downloads/" target="about:blank">Geth &amp; Tools</a> bundles, but can also be installed separately via:<pre>go get github.com/ethereum/go-ethereum/cmd/puppeth</pre></p>
+ <br/>
+ <p><em>Copyright 2017. The go-ethereum Authors.</em></p>
+ </div>
+ <div style="display: inline-block; vertical-align: bottom; width: 217px;">
+ <img src="puppeth.png" style="height: 256px; margin: 16px 16px 16px 16px"></img>
+ </div>
+ </div>
+ </div>
+ </div>
+ </div>
<div id="frame-wrapper" hidden style="position: absolute; height: 100%;">
- <iframe id="frame" style="position: absolute; width: 1920px; height: 100%; border: none;" onload="if ($(this).attr('src') != '') { resize(); $('#frame-wrapper').fadeIn(300); }"></iframe>
- </div>
- </div>
- </div>
- </div>
-
- <script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.2.0/jquery.min.js"></script>
- <script src="https://cdnjs.cloudflare.com/ajax/libs/twitter-bootstrap/3.3.7/js/bootstrap.min.js"></script>
- <script src="https://cdnjs.cloudflare.com/ajax/libs/gentelella/1.3.0/js/custom.min.js"></script>
- <script>
- var load = function(url) {
- $("#connect-go-ethereum-geth").fadeOut(300)
- $("#connect-go-ethereum-mist").fadeOut(300)
- $("#connect-go-ethereum-mobile").fadeOut(300)
- $("#about").fadeOut(300)
- $("#frame-wrapper").fadeOut(300);
-
- setTimeout(function() {
- if (url.substring(0, 1) == "#") {
- $('.body').css({overflowY: 'auto'});
- $("#frame").attr("src", "");
- $(url).fadeIn(300);
- } else {
- $('.body').css({overflowY: 'hidden'});
- $("#frame").attr("src", url);
- }
- }, 300);
- }
- var resize = function() {
- var sidebar = $($(".navbar")[0]).width();
- var content = 1920;
- var limit = document.body.clientWidth - sidebar;
- var scale = limit / content;
-
- console.log(document.body.clientHeight);
-
- $("#frame-wrapper").width(content / scale);
- $("#frame-wrapper").height(document.body.clientHeight / scale);
- $("#frame-wrapper").css({
- transform: 'scale(' + (scale) + ')',
- transformOrigin: "0 0"
- });
- };
+ <iframe id="frame" style="position: absolute; width: 1920px; height: 100%; border: none;" onload="if ($(this).attr('src') != '') { resize(); $('#frame-wrapper').fadeIn(300); }"></iframe>
+ </div>
+ </div>
+ </div>
+ </div>
+
+ <script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.2.0/jquery.min.js"></script>
+ <script src="https://cdnjs.cloudflare.com/ajax/libs/twitter-bootstrap/3.3.7/js/bootstrap.min.js"></script>
+ <script src="https://cdnjs.cloudflare.com/ajax/libs/gentelella/1.3.0/js/custom.min.js"></script>
+ <script>
+ var load = function(url) {
+ $("#connect-go-ethereum-geth").fadeOut(300)
+ $("#connect-go-ethereum-mist").fadeOut(300)
+ $("#connect-go-ethereum-mobile").fadeOut(300)
+ $("#about").fadeOut(300)
+ $("#frame-wrapper").fadeOut(300);
+
+ setTimeout(function() {
+ if (url.substring(0, 1) == "#") {
+ $('.body').css({overflowY: 'auto'});
+ $("#frame").attr("src", "");
+ $(url).fadeIn(300);
+ } else {
+ $('.body').css({overflowY: 'hidden'});
+ $("#frame").attr("src", url);
+ }
+ }, 300);
+ }
+ var resize = function() {
+ var sidebar = $($(".navbar")[0]).width();
+ var content = 1920;
+ var limit = document.body.clientWidth - sidebar;
+ var scale = limit / content;
+
+ console.log(document.body.clientHeight);
+
+ $("#frame-wrapper").width(content / scale);
+ $("#frame-wrapper").height(document.body.clientHeight / scale);
+ $("#frame-wrapper").css({
+ transform: 'scale(' + (scale) + ')',
+ transformOrigin: "0 0"
+ });
+ };
$(window).resize(resize);
var item = $(".side-menu").children()[0];
$(item).children()[0].click();
$(item).addClass("active");
- </script>
- </body>
+ </script>
+ </body>
</html>
`
@@ -396,7 +396,7 @@ var dashboardDockerfile = `
FROM mhart/alpine-node:latest
RUN \
- npm install connect serve-static && \
+ npm install connect serve-static && \
\
echo 'var connect = require("connect");' > server.js && \
echo 'var serveStatic = require("serve-static");' >> server.js && \
diff --git a/cmd/swarm/main.go b/cmd/swarm/main.go
index bbd0cb1b3..833083b91 100644
--- a/cmd/swarm/main.go
+++ b/cmd/swarm/main.go
@@ -39,19 +39,16 @@ import (
"github.com/ethereum/go-ethereum/node"
"github.com/ethereum/go-ethereum/p2p"
"github.com/ethereum/go-ethereum/p2p/discover"
+ "github.com/ethereum/go-ethereum/params"
"github.com/ethereum/go-ethereum/swarm"
bzzapi "github.com/ethereum/go-ethereum/swarm/api"
"gopkg.in/urfave/cli.v1"
)
-const (
- clientIdentifier = "swarm"
- versionString = "0.2"
-)
+const clientIdentifier = "swarm"
var (
gitCommit string // Git SHA1 commit hash of the release (set via linker flags)
- app = utils.NewApp(gitCommit, "Ethereum Swarm")
testbetBootNodes = []string{
"enode://ec8ae764f7cb0417bdfb009b9d0f18ab3818a3a4e8e7c67dd5f18971a93510a2e6f43cd0b69a27e439a9629457ea804104f37c85e41eed057d3faabbf7744cdf@13.74.157.139:30429",
"enode://c2e1fceb3bf3be19dff71eec6cccf19f2dbf7567ee017d130240c670be8594bc9163353ca55dd8df7a4f161dd94b36d0615c17418b5a3cdcbb4e9d99dfa4de37@13.74.157.139:30430",
@@ -126,13 +123,22 @@ var (
}
)
+var defaultNodeConfig = node.DefaultConfig
+
+// This init function sets defaults so cmd/swarm can run alongside geth.
func init() {
- // Override flag defaults so bzzd can run alongside geth.
+ defaultNodeConfig.Name = clientIdentifier
+ defaultNodeConfig.Version = params.VersionWithCommit(gitCommit)
+ defaultNodeConfig.P2P.ListenAddr = ":30399"
+ defaultNodeConfig.IPCPath = "bzzd.ipc"
+ // Set flag defaults for --help display.
utils.ListenPortFlag.Value = 30399
- utils.IPCPathFlag.Value = utils.DirectoryString{Value: "bzzd.ipc"}
- utils.IPCApiFlag.Value = "admin, bzz, chequebook, debug, rpc, swarmfs, web3"
+}
- // Set up the cli app.
+var app = utils.NewApp(gitCommit, "Ethereum Swarm")
+
+// This init function creates the cli.App.
+func init() {
app.Action = bzzd
app.HideVersion = true // we have a command to print the version
app.Copyright = "Copyright 2013-2016 The go-ethereum Authors"
@@ -235,7 +241,6 @@ Cleans database of corrupted entries.
utils.MaxPeersFlag,
utils.NATFlag,
utils.IPCDisabledFlag,
- utils.IPCApiFlag,
utils.IPCPathFlag,
utils.PasswordFileFlag,
// bzzd-specific flags
@@ -276,7 +281,7 @@ func main() {
func version(ctx *cli.Context) error {
fmt.Println(strings.Title(clientIdentifier))
- fmt.Println("Version:", versionString)
+ fmt.Println("Version:", params.Version)
if gitCommit != "" {
fmt.Println("Git Commit:", gitCommit)
}
@@ -289,9 +294,16 @@ func version(ctx *cli.Context) error {
}
func bzzd(ctx *cli.Context) error {
- stack := utils.MakeNode(ctx, clientIdentifier, gitCommit)
+ cfg := defaultNodeConfig
+ utils.SetNodeConfig(ctx, &cfg)
+ stack, err := node.New(&cfg)
+ if err != nil {
+ utils.Fatalf("can't create node: %v", err)
+ }
+
registerBzzService(ctx, stack)
utils.StartNode(stack)
+
go func() {
sigc := make(chan os.Signal, 1)
signal.Notify(sigc, syscall.SIGTERM)
@@ -300,6 +312,7 @@ func bzzd(ctx *cli.Context) error {
log.Info("Got sigterm, shutting swarm down...")
stack.Stop()
}()
+
networkId := ctx.GlobalUint64(SwarmNetworkIdFlag.Name)
// Add bootnodes as initial peers.
if ctx.GlobalIsSet(utils.BootnodesFlag.Name) {
@@ -316,7 +329,6 @@ func bzzd(ctx *cli.Context) error {
}
func registerBzzService(ctx *cli.Context, stack *node.Node) {
-
prvkey := getAccount(ctx, stack)
chbookaddr := common.HexToAddress(ctx.GlobalString(ChequebookAddrFlag.Name))
diff --git a/cmd/utils/customflags.go b/cmd/utils/customflags.go
index 00f28f2ec..e5bf8724c 100644
--- a/cmd/utils/customflags.go
+++ b/cmd/utils/customflags.go
@@ -17,6 +17,7 @@
package utils
import (
+ "encoding"
"errors"
"flag"
"fmt"
@@ -78,6 +79,58 @@ func (self DirectoryFlag) Apply(set *flag.FlagSet) {
})
}
+type TextMarshaler interface {
+ encoding.TextMarshaler
+ encoding.TextUnmarshaler
+}
+
+// textMarshalerVal turns a TextMarshaler into a flag.Value
+type textMarshalerVal struct {
+ v TextMarshaler
+}
+
+func (v textMarshalerVal) String() string {
+ if v.v == nil {
+ return ""
+ }
+ text, _ := v.v.MarshalText()
+ return string(text)
+}
+
+func (v textMarshalerVal) Set(s string) error {
+ return v.v.UnmarshalText([]byte(s))
+}
+
+// TextMarshalerFlag wraps a TextMarshaler value.
+type TextMarshalerFlag struct {
+ Name string
+ Value TextMarshaler
+ Usage string
+}
+
+func (f TextMarshalerFlag) GetName() string {
+ return f.Name
+}
+
+func (f TextMarshalerFlag) String() string {
+ return fmt.Sprintf("%s \"%v\"\t%v", prefixedNames(f.Name), f.Value, f.Usage)
+}
+
+func (f TextMarshalerFlag) Apply(set *flag.FlagSet) {
+ eachName(f.Name, func(name string) {
+ set.Var(textMarshalerVal{f.Value}, f.Name, f.Usage)
+ })
+}
+
+// GlobalTextMarshaler returns the value of a TextMarshalerFlag from the global flag set.
+func GlobalTextMarshaler(ctx *cli.Context, name string) TextMarshaler {
+ val := ctx.GlobalGeneric(name)
+ if val == nil {
+ return nil
+ }
+ return val.(textMarshalerVal).v
+}
+
// BigFlag is a command line flag that accepts 256 bit big integers in decimal or
// hexadecimal syntax.
type BigFlag struct {
diff --git a/cmd/utils/flags.go b/cmd/utils/flags.go
index 0ca407a75..1bd77139c 100644
--- a/cmd/utils/flags.go
+++ b/cmd/utils/flags.go
@@ -23,7 +23,6 @@ import (
"io/ioutil"
"math/big"
"os"
- "os/user"
"path/filepath"
"runtime"
"strconv"
@@ -38,6 +37,8 @@ import (
"github.com/ethereum/go-ethereum/core/vm"
"github.com/ethereum/go-ethereum/crypto"
"github.com/ethereum/go-ethereum/eth"
+ "github.com/ethereum/go-ethereum/eth/downloader"
+ "github.com/ethereum/go-ethereum/eth/gasprice"
"github.com/ethereum/go-ethereum/ethdb"
"github.com/ethereum/go-ethereum/ethstats"
"github.com/ethereum/go-ethereum/event"
@@ -45,12 +46,12 @@ import (
"github.com/ethereum/go-ethereum/log"
"github.com/ethereum/go-ethereum/metrics"
"github.com/ethereum/go-ethereum/node"
+ "github.com/ethereum/go-ethereum/p2p"
"github.com/ethereum/go-ethereum/p2p/discover"
"github.com/ethereum/go-ethereum/p2p/discv5"
"github.com/ethereum/go-ethereum/p2p/nat"
"github.com/ethereum/go-ethereum/p2p/netutil"
"github.com/ethereum/go-ethereum/params"
- "github.com/ethereum/go-ethereum/rpc"
whisper "github.com/ethereum/go-ethereum/whisper/whisperv2"
"gopkg.in/urfave/cli.v1"
)
@@ -121,31 +122,32 @@ var (
EthashCachesInMemoryFlag = cli.IntFlag{
Name: "ethash.cachesinmem",
Usage: "Number of recent ethash caches to keep in memory (16MB each)",
- Value: 2,
+ Value: eth.DefaultConfig.EthashCachesInMem,
}
EthashCachesOnDiskFlag = cli.IntFlag{
Name: "ethash.cachesondisk",
Usage: "Number of recent ethash caches to keep on disk (16MB each)",
- Value: 3,
+ Value: eth.DefaultConfig.EthashCachesOnDisk,
}
EthashDatasetDirFlag = DirectoryFlag{
Name: "ethash.dagdir",
Usage: "Directory to store the ethash mining DAGs (default = inside home folder)",
+ Value: DirectoryString{eth.DefaultConfig.EthashDatasetDir},
}
EthashDatasetsInMemoryFlag = cli.IntFlag{
Name: "ethash.dagsinmem",
Usage: "Number of recent ethash mining DAGs to keep in memory (1+GB each)",
- Value: 1,
+ Value: eth.DefaultConfig.EthashDatasetsInMem,
}
EthashDatasetsOnDiskFlag = cli.IntFlag{
Name: "ethash.dagsondisk",
Usage: "Number of recent ethash mining DAGs to keep on disk (1+GB each)",
- Value: 2,
+ Value: eth.DefaultConfig.EthashDatasetsOnDisk,
}
NetworkIdFlag = cli.IntFlag{
Name: "networkid",
Usage: "Network identifier (integer, 1=Frontier, 2=Morden (disused), 3=Ropsten)",
- Value: eth.NetworkId,
+ Value: eth.DefaultConfig.NetworkId,
}
TestNetFlag = cli.BoolFlag{
Name: "testnet",
@@ -172,6 +174,13 @@ var (
Name: "light",
Usage: "Enable light client mode",
}
+ defaultSyncMode = eth.DefaultConfig.SyncMode
+ SyncModeFlag = TextMarshalerFlag{
+ Name: "syncmode",
+ Usage: `Blockchain sync mode ("fast", "full", or "light")`,
+ Value: &defaultSyncMode,
+ }
+
LightServFlag = cli.IntFlag{
Name: "lightserv",
Usage: "Maximum percentage of time allowed for serving LES requests (0-90)",
@@ -238,19 +247,6 @@ var (
Value: "",
}
- VMForceJitFlag = cli.BoolFlag{
- Name: "forcejit",
- Usage: "Force the JIT VM to take precedence",
- }
- VMJitCacheFlag = cli.IntFlag{
- Name: "jitcache",
- Usage: "Amount of cached JIT VM programs",
- Value: 64,
- }
- VMEnableJitFlag = cli.BoolFlag{
- Name: "jitvm",
- Usage: "Enable the JIT VM",
- }
VMEnableDebugFlag = cli.BoolFlag{
Name: "vmdebug",
Usage: "Record information useful for VM and contract debugging",
@@ -295,21 +291,15 @@ var (
RPCApiFlag = cli.StringFlag{
Name: "rpcapi",
Usage: "API's offered over the HTTP-RPC interface",
- Value: rpc.DefaultHTTPApis,
+ Value: "",
}
IPCDisabledFlag = cli.BoolFlag{
Name: "ipcdisable",
Usage: "Disable the IPC-RPC server",
}
- IPCApiFlag = cli.StringFlag{
- Name: "ipcapi",
- Usage: "APIs offered over the IPC-RPC interface",
- Value: rpc.DefaultIPCApis,
- }
IPCPathFlag = DirectoryFlag{
Name: "ipcpath",
Usage: "Filename for IPC socket/pipe within the datadir (explicit paths escape it)",
- Value: DirectoryString{"geth.ipc"},
}
WSEnabledFlag = cli.BoolFlag{
Name: "ws",
@@ -328,7 +318,7 @@ var (
WSApiFlag = cli.StringFlag{
Name: "wsapi",
Usage: "API's offered over the WS-RPC interface",
- Value: rpc.DefaultHTTPApis,
+ Value: "",
}
WSAllowedOriginsFlag = cli.StringFlag{
Name: "wsorigins",
@@ -412,12 +402,12 @@ var (
GpoBlocksFlag = cli.IntFlag{
Name: "gpoblocks",
Usage: "Number of recent blocks to check for gas prices",
- Value: 10,
+ Value: eth.DefaultConfig.GPO.Blocks,
}
GpoPercentileFlag = cli.IntFlag{
Name: "gpopercentile",
Usage: "Suggested gas price is the given percentile of a set of recent transaction gas prices",
- Value: 50,
+ Value: eth.DefaultConfig.GPO.Percentile,
}
)
@@ -436,88 +426,42 @@ func MakeDataDir(ctx *cli.Context) string {
return ""
}
-// MakeEthashCacheDir returns the directory to use for storing the ethash cache
-// dumps.
-func MakeEthashCacheDir(ctx *cli.Context) string {
- if ctx.GlobalIsSet(EthashCacheDirFlag.Name) && ctx.GlobalString(EthashCacheDirFlag.Name) == "" {
- return ""
- }
- if !ctx.GlobalIsSet(EthashCacheDirFlag.Name) {
- return "ethash"
- }
- return ctx.GlobalString(EthashCacheDirFlag.Name)
-}
-
-// MakeEthashDatasetDir returns the directory to use for storing the full ethash
-// dataset dumps.
-func MakeEthashDatasetDir(ctx *cli.Context) string {
- if !ctx.GlobalIsSet(EthashDatasetDirFlag.Name) {
- home := os.Getenv("HOME")
- if home == "" {
- if user, err := user.Current(); err == nil {
- home = user.HomeDir
- }
- }
- if runtime.GOOS == "windows" {
- return filepath.Join(home, "AppData", "Ethash")
- }
- return filepath.Join(home, ".ethash")
- }
- return ctx.GlobalString(EthashDatasetDirFlag.Name)
-}
-
-// MakeIPCPath creates an IPC path configuration from the set command line flags,
-// returning an empty string if IPC was explicitly disabled, or the set path.
-func MakeIPCPath(ctx *cli.Context) string {
- if ctx.GlobalBool(IPCDisabledFlag.Name) {
- return ""
- }
- return ctx.GlobalString(IPCPathFlag.Name)
-}
-
-// MakeNodeKey creates a node key from set command line flags, either loading it
+// setNodeKey creates a node key from set command line flags, either loading it
// from a file or as a specified hex value. If neither flags were provided, this
// method returns nil and an emphemeral key is to be generated.
-func MakeNodeKey(ctx *cli.Context) *ecdsa.PrivateKey {
+func setNodeKey(ctx *cli.Context, cfg *p2p.Config) {
var (
hex = ctx.GlobalString(NodeKeyHexFlag.Name)
file = ctx.GlobalString(NodeKeyFileFlag.Name)
-
- key *ecdsa.PrivateKey
- err error
+ key *ecdsa.PrivateKey
+ err error
)
switch {
case file != "" && hex != "":
Fatalf("Options %q and %q are mutually exclusive", NodeKeyFileFlag.Name, NodeKeyHexFlag.Name)
-
case file != "":
if key, err = crypto.LoadECDSA(file); err != nil {
Fatalf("Option %q: %v", NodeKeyFileFlag.Name, err)
}
-
+ cfg.PrivateKey = key
case hex != "":
if key, err = crypto.HexToECDSA(hex); err != nil {
Fatalf("Option %q: %v", NodeKeyHexFlag.Name, err)
}
+ cfg.PrivateKey = key
}
- return key
}
-// makeNodeUserIdent creates the user identifier from CLI flags.
-func makeNodeUserIdent(ctx *cli.Context) string {
- var comps []string
+// setNodeUserIdent creates the user identifier from CLI flags.
+func setNodeUserIdent(ctx *cli.Context, cfg *node.Config) {
if identity := ctx.GlobalString(IdentityFlag.Name); len(identity) > 0 {
- comps = append(comps, identity)
+ cfg.UserIdent = identity
}
- if ctx.GlobalBool(VMEnableJitFlag.Name) {
- comps = append(comps, "JIT")
- }
- return strings.Join(comps, "/")
}
-// MakeBootstrapNodes creates a list of bootstrap nodes from the command line
+// setBootstrapNodes creates a list of bootstrap nodes from the command line
// flags, reverting to pre-configured ones if none have been specified.
-func MakeBootstrapNodes(ctx *cli.Context) []*discover.Node {
+func setBootstrapNodes(ctx *cli.Context, cfg *p2p.Config) {
urls := params.MainnetBootnodes
if ctx.GlobalIsSet(BootnodesFlag.Name) {
urls = strings.Split(ctx.GlobalString(BootnodesFlag.Name), ",")
@@ -525,62 +469,68 @@ func MakeBootstrapNodes(ctx *cli.Context) []*discover.Node {
urls = params.TestnetBootnodes
}
- bootnodes := make([]*discover.Node, 0, len(urls))
+ cfg.BootstrapNodes = make([]*discover.Node, 0, len(urls))
for _, url := range urls {
node, err := discover.ParseNode(url)
if err != nil {
log.Error("Bootstrap URL invalid", "enode", url, "err", err)
continue
}
- bootnodes = append(bootnodes, node)
+ cfg.BootstrapNodes = append(cfg.BootstrapNodes, node)
}
- return bootnodes
}
-// MakeBootstrapNodesV5 creates a list of bootstrap nodes from the command line
+// setBootstrapNodesV5 creates a list of bootstrap nodes from the command line
// flags, reverting to pre-configured ones if none have been specified.
-func MakeBootstrapNodesV5(ctx *cli.Context) []*discv5.Node {
+func setBootstrapNodesV5(ctx *cli.Context, cfg *p2p.Config) {
urls := params.DiscoveryV5Bootnodes
if ctx.GlobalIsSet(BootnodesFlag.Name) {
urls = strings.Split(ctx.GlobalString(BootnodesFlag.Name), ",")
+ } else if cfg.BootstrapNodesV5 == nil {
+ return // already set, don't apply defaults.
}
- bootnodes := make([]*discv5.Node, 0, len(urls))
+ cfg.BootstrapNodesV5 = make([]*discv5.Node, 0, len(urls))
for _, url := range urls {
node, err := discv5.ParseNode(url)
if err != nil {
log.Error("Bootstrap URL invalid", "enode", url, "err", err)
continue
}
- bootnodes = append(bootnodes, node)
+ cfg.BootstrapNodesV5 = append(cfg.BootstrapNodesV5, node)
}
- return bootnodes
}
-// MakeListenAddress creates a TCP listening address string from set command
+// setListenAddress creates a TCP listening address string from set command
// line flags.
-func MakeListenAddress(ctx *cli.Context) string {
- return fmt.Sprintf(":%d", ctx.GlobalInt(ListenPortFlag.Name))
+func setListenAddress(ctx *cli.Context, cfg *p2p.Config) {
+ if ctx.GlobalIsSet(ListenPortFlag.Name) {
+ cfg.ListenAddr = fmt.Sprintf(":%d", ctx.GlobalInt(ListenPortFlag.Name))
+ }
}
-// MakeDiscoveryV5Address creates a UDP listening address string from set command
+// setDiscoveryV5Address creates a UDP listening address string from set command
// line flags for the V5 discovery protocol.
-func MakeDiscoveryV5Address(ctx *cli.Context) string {
- return fmt.Sprintf(":%d", ctx.GlobalInt(ListenPortFlag.Name)+1)
+func setDiscoveryV5Address(ctx *cli.Context, cfg *p2p.Config) {
+ if ctx.GlobalIsSet(ListenPortFlag.Name) {
+ cfg.DiscoveryV5Addr = fmt.Sprintf(":%d", ctx.GlobalInt(ListenPortFlag.Name)+1)
+ }
}
-// MakeNAT creates a port mapper from set command line flags.
-func MakeNAT(ctx *cli.Context) nat.Interface {
- natif, err := nat.Parse(ctx.GlobalString(NATFlag.Name))
- if err != nil {
- Fatalf("Option %s: %v", NATFlag.Name, err)
+// setNAT creates a port mapper from command line flags.
+func setNAT(ctx *cli.Context, cfg *p2p.Config) {
+ if ctx.GlobalIsSet(NATFlag.Name) {
+ natif, err := nat.Parse(ctx.GlobalString(NATFlag.Name))
+ if err != nil {
+ Fatalf("Option %s: %v", NATFlag.Name, err)
+ }
+ cfg.NAT = natif
}
- return natif
}
-// MakeRPCModules splits input separated by a comma and trims excessive white
+// makeRPCModules splits input separated by a comma and trims excessive white
// space from the substrings.
-func MakeRPCModules(input string) []string {
+func makeRPCModules(input string) []string {
result := strings.Split(input, ",")
for i, r := range result {
result[i] = strings.TrimSpace(r)
@@ -588,27 +538,63 @@ func MakeRPCModules(input string) []string {
return result
}
-// MakeHTTPRpcHost creates the HTTP RPC listener interface string from the set
+// setHTTP creates the HTTP RPC listener interface string from the set
// command line flags, returning empty if the HTTP endpoint is disabled.
-func MakeHTTPRpcHost(ctx *cli.Context) string {
- if !ctx.GlobalBool(RPCEnabledFlag.Name) {
- return ""
+func setHTTP(ctx *cli.Context, cfg *node.Config) {
+ if ctx.GlobalBool(RPCEnabledFlag.Name) && cfg.HTTPHost == "" {
+ cfg.HTTPHost = "127.0.0.1"
+ if ctx.GlobalIsSet(RPCListenAddrFlag.Name) {
+ cfg.HTTPHost = ctx.GlobalString(RPCListenAddrFlag.Name)
+ }
+ }
+
+ if ctx.GlobalIsSet(RPCPortFlag.Name) {
+ cfg.HTTPPort = ctx.GlobalInt(RPCPortFlag.Name)
+ }
+ if ctx.GlobalIsSet(RPCCORSDomainFlag.Name) {
+ cfg.HTTPCors = ctx.GlobalString(RPCCORSDomainFlag.Name)
+ }
+ if ctx.GlobalIsSet(RPCApiFlag.Name) {
+ cfg.HTTPModules = makeRPCModules(ctx.GlobalString(RPCApiFlag.Name))
}
- return ctx.GlobalString(RPCListenAddrFlag.Name)
}
-// MakeWSRpcHost creates the WebSocket RPC listener interface string from the set
+// setWS creates the WebSocket RPC listener interface string from the set
// command line flags, returning empty if the HTTP endpoint is disabled.
-func MakeWSRpcHost(ctx *cli.Context) string {
- if !ctx.GlobalBool(WSEnabledFlag.Name) {
- return ""
+func setWS(ctx *cli.Context, cfg *node.Config) {
+ if ctx.GlobalBool(WSEnabledFlag.Name) && cfg.WSHost == "" {
+ cfg.WSHost = "127.0.0.1"
+ if ctx.GlobalIsSet(WSListenAddrFlag.Name) {
+ cfg.WSHost = ctx.GlobalString(WSListenAddrFlag.Name)
+ }
+ }
+
+ if ctx.GlobalIsSet(WSPortFlag.Name) {
+ cfg.WSPort = ctx.GlobalInt(WSPortFlag.Name)
+ }
+ if ctx.GlobalIsSet(WSAllowedOriginsFlag.Name) {
+ cfg.WSOrigins = ctx.GlobalString(WSAllowedOriginsFlag.Name)
+ }
+ if ctx.GlobalIsSet(WSApiFlag.Name) {
+ cfg.WSModules = makeRPCModules(ctx.GlobalString(WSApiFlag.Name))
+ }
+}
+
+// setIPC creates an IPC path configuration from the set command line flags,
+// returning an empty string if IPC was explicitly disabled, or the set path.
+func setIPC(ctx *cli.Context, cfg *node.Config) {
+ checkExclusive(ctx, IPCDisabledFlag, IPCPathFlag)
+ switch {
+ case ctx.GlobalBool(IPCDisabledFlag.Name):
+ cfg.IPCPath = ""
+ case ctx.GlobalIsSet(IPCPathFlag.Name):
+ cfg.IPCPath = ctx.GlobalString(IPCPathFlag.Name)
}
- return ctx.GlobalString(WSListenAddrFlag.Name)
}
-// MakeDatabaseHandles raises out the number of allowed file handles per process
+// makeDatabaseHandles raises out the number of allowed file handles per process
// for Geth and returns half of the allowance to assign to the database.
-func MakeDatabaseHandles() int {
+func makeDatabaseHandles() int {
if err := raiseFdLimit(2048); err != nil {
Fatalf("Failed to raise file descriptor allowance: %v", err)
}
@@ -641,33 +627,25 @@ func MakeAddress(ks *keystore.KeyStore, account string) (accounts.Account, error
return accs[index], nil
}
-// MakeEtherbase retrieves the etherbase either from the directly specified
+// setEtherbase retrieves the etherbase either from the directly specified
// command line flags or from the keystore if CLI indexed.
-func MakeEtherbase(ks *keystore.KeyStore, ctx *cli.Context) common.Address {
- accounts := ks.Accounts()
- if !ctx.GlobalIsSet(EtherbaseFlag.Name) && len(accounts) == 0 {
- log.Warn("No etherbase set and no accounts found as default")
- return common.Address{}
- }
- etherbase := ctx.GlobalString(EtherbaseFlag.Name)
- if etherbase == "" {
- return common.Address{}
- }
- // If the specified etherbase is a valid address, return it
- account, err := MakeAddress(ks, etherbase)
- if err != nil {
- Fatalf("Option %q: %v", EtherbaseFlag.Name, err)
+func setEtherbase(ctx *cli.Context, ks *keystore.KeyStore, cfg *eth.Config) {
+ if ctx.GlobalIsSet(EtherbaseFlag.Name) {
+ account, err := MakeAddress(ks, ctx.GlobalString(EtherbaseFlag.Name))
+ if err != nil {
+ Fatalf("Option %q: %v", EtherbaseFlag.Name, err)
+ }
+ cfg.Etherbase = account.Address
+ return
}
- return account.Address
-}
-
-// MakeMinerExtra resolves extradata for the miner from the set command line flags
-// or returns a default one composed on the client, runtime and OS metadata.
-func MakeMinerExtra(extra []byte, ctx *cli.Context) []byte {
- if ctx.GlobalIsSet(ExtraDataFlag.Name) {
- return []byte(ctx.GlobalString(ExtraDataFlag.Name))
+ accounts := ks.Accounts()
+ if (cfg.Etherbase == common.Address{}) {
+ if len(accounts) > 0 {
+ cfg.Etherbase = accounts[0].Address
+ } else {
+ log.Warn("No etherbase set and no accounts found as default")
+ }
}
- return extra
}
// MakePasswordList reads password lines from the file specified by --password.
@@ -688,144 +666,217 @@ func MakePasswordList(ctx *cli.Context) []string {
return lines
}
-// MakeNode configures a node with no services from command line flags.
-func MakeNode(ctx *cli.Context, name, gitCommit string) *node.Node {
- vsn := params.Version
- if gitCommit != "" {
- vsn += "-" + gitCommit[:8]
+func SetP2PConfig(ctx *cli.Context, cfg *p2p.Config) {
+ setNodeKey(ctx, cfg)
+ setNAT(ctx, cfg)
+ setListenAddress(ctx, cfg)
+ setDiscoveryV5Address(ctx, cfg)
+ setBootstrapNodes(ctx, cfg)
+ setBootstrapNodesV5(ctx, cfg)
+
+ if ctx.GlobalIsSet(MaxPeersFlag.Name) {
+ cfg.MaxPeers = ctx.GlobalInt(MaxPeersFlag.Name)
+ }
+ if ctx.GlobalIsSet(MaxPendingPeersFlag.Name) {
+ cfg.MaxPendingPeers = ctx.GlobalInt(MaxPendingPeersFlag.Name)
+ }
+ if ctx.GlobalIsSet(NoDiscoverFlag.Name) || ctx.GlobalBool(LightModeFlag.Name) {
+ cfg.NoDiscovery = true
}
- // if we're running a light client or server, force enable the v5 peer discovery unless it is explicitly disabled with --nodiscover
- // note that explicitly specifying --v5disc overrides --nodiscover, in which case the later only disables v4 discovery
+ // if we're running a light client or server, force enable the v5 peer discovery
+ // unless it is explicitly disabled with --nodiscover note that explicitly specifying
+ // --v5disc overrides --nodiscover, in which case the later only disables v4 discovery
forceV5Discovery := (ctx.GlobalBool(LightModeFlag.Name) || ctx.GlobalInt(LightServFlag.Name) > 0) && !ctx.GlobalBool(NoDiscoverFlag.Name)
-
- config := &node.Config{
- DataDir: MakeDataDir(ctx),
- KeyStoreDir: ctx.GlobalString(KeyStoreDirFlag.Name),
- UseLightweightKDF: ctx.GlobalBool(LightKDFFlag.Name),
- PrivateKey: MakeNodeKey(ctx),
- Name: name,
- Version: vsn,
- UserIdent: makeNodeUserIdent(ctx),
- NoDiscovery: ctx.GlobalBool(NoDiscoverFlag.Name) || ctx.GlobalBool(LightModeFlag.Name), // always disable v4 discovery in light client mode
- DiscoveryV5: ctx.GlobalBool(DiscoveryV5Flag.Name) || forceV5Discovery,
- DiscoveryV5Addr: MakeDiscoveryV5Address(ctx),
- BootstrapNodes: MakeBootstrapNodes(ctx),
- BootstrapNodesV5: MakeBootstrapNodesV5(ctx),
- ListenAddr: MakeListenAddress(ctx),
- NAT: MakeNAT(ctx),
- MaxPeers: ctx.GlobalInt(MaxPeersFlag.Name),
- MaxPendingPeers: ctx.GlobalInt(MaxPendingPeersFlag.Name),
- IPCPath: MakeIPCPath(ctx),
- HTTPHost: MakeHTTPRpcHost(ctx),
- HTTPPort: ctx.GlobalInt(RPCPortFlag.Name),
- HTTPCors: ctx.GlobalString(RPCCORSDomainFlag.Name),
- HTTPModules: MakeRPCModules(ctx.GlobalString(RPCApiFlag.Name)),
- WSHost: MakeWSRpcHost(ctx),
- WSPort: ctx.GlobalInt(WSPortFlag.Name),
- WSOrigins: ctx.GlobalString(WSAllowedOriginsFlag.Name),
- WSModules: MakeRPCModules(ctx.GlobalString(WSApiFlag.Name)),
- }
- if ctx.GlobalBool(DevModeFlag.Name) {
- if !ctx.GlobalIsSet(DataDirFlag.Name) {
- config.DataDir = filepath.Join(os.TempDir(), "/ethereum_dev_mode")
- }
- // --dev mode does not need p2p networking.
- config.MaxPeers = 0
- config.ListenAddr = ":0"
+ if ctx.GlobalIsSet(DiscoveryV5Flag.Name) {
+ cfg.DiscoveryV5 = ctx.GlobalBool(DiscoveryV5Flag.Name)
+ } else if forceV5Discovery {
+ cfg.DiscoveryV5 = true
}
+
if netrestrict := ctx.GlobalString(NetrestrictFlag.Name); netrestrict != "" {
list, err := netutil.ParseNetlist(netrestrict)
if err != nil {
Fatalf("Option %q: %v", NetrestrictFlag.Name, err)
}
- config.NetRestrict = list
+ cfg.NetRestrict = list
}
- stack, err := node.New(config)
- if err != nil {
- Fatalf("Failed to create the protocol stack: %v", err)
+ if ctx.GlobalBool(DevModeFlag.Name) {
+ // --dev mode can't use p2p networking.
+ cfg.MaxPeers = 0
+ cfg.ListenAddr = ":0"
+ cfg.NoDiscovery = true
+ cfg.DiscoveryV5 = false
}
- return stack
}
-// RegisterEthService configures eth.Ethereum from command line flags and adds it to the
-// given node.
-func RegisterEthService(ctx *cli.Context, stack *node.Node, extra []byte) {
- // Avoid conflicting network flags
- networks, netFlags := 0, []cli.BoolFlag{DevModeFlag, TestNetFlag}
- for _, flag := range netFlags {
- if ctx.GlobalBool(flag.Name) {
- networks++
+// SetNodeConfig applies node-related command line flags to the config.
+func SetNodeConfig(ctx *cli.Context, cfg *node.Config) {
+ SetP2PConfig(ctx, &cfg.P2P)
+ setIPC(ctx, cfg)
+ setHTTP(ctx, cfg)
+ setWS(ctx, cfg)
+ setNodeUserIdent(ctx, cfg)
+
+ switch {
+ case ctx.GlobalIsSet(DataDirFlag.Name):
+ cfg.DataDir = ctx.GlobalString(DataDirFlag.Name)
+ case ctx.GlobalBool(DevModeFlag.Name):
+ cfg.DataDir = filepath.Join(os.TempDir(), "ethereum_dev_mode")
+ case ctx.GlobalBool(TestNetFlag.Name):
+ cfg.DataDir = filepath.Join(node.DefaultDataDir(), "testnet")
+ }
+
+ if ctx.GlobalIsSet(KeyStoreDirFlag.Name) {
+ cfg.KeyStoreDir = ctx.GlobalString(KeyStoreDirFlag.Name)
+ }
+ if ctx.GlobalIsSet(LightKDFFlag.Name) {
+ cfg.UseLightweightKDF = ctx.GlobalBool(LightKDFFlag.Name)
+ }
+}
+
+func setGPO(ctx *cli.Context, cfg *gasprice.Config) {
+ if ctx.GlobalIsSet(GpoBlocksFlag.Name) {
+ cfg.Blocks = ctx.GlobalInt(GpoBlocksFlag.Name)
+ }
+ if ctx.GlobalIsSet(GpoPercentileFlag.Name) {
+ cfg.Percentile = ctx.GlobalInt(GpoPercentileFlag.Name)
+ }
+}
+
+func setEthash(ctx *cli.Context, cfg *eth.Config) {
+ if ctx.GlobalIsSet(EthashCacheDirFlag.Name) {
+ cfg.EthashCacheDir = ctx.GlobalString(EthashCacheDirFlag.Name)
+ }
+ if ctx.GlobalIsSet(EthashDatasetDirFlag.Name) {
+ cfg.EthashDatasetDir = ctx.GlobalString(EthashDatasetDirFlag.Name)
+ }
+ if ctx.GlobalIsSet(EthashCachesInMemoryFlag.Name) {
+ cfg.EthashCachesInMem = ctx.GlobalInt(EthashCachesInMemoryFlag.Name)
+ }
+ if ctx.GlobalIsSet(EthashCachesOnDiskFlag.Name) {
+ cfg.EthashCachesOnDisk = ctx.GlobalInt(EthashCachesOnDiskFlag.Name)
+ }
+ if ctx.GlobalIsSet(EthashDatasetsInMemoryFlag.Name) {
+ cfg.EthashDatasetsInMem = ctx.GlobalInt(EthashDatasetsInMemoryFlag.Name)
+ }
+ if ctx.GlobalIsSet(EthashDatasetsOnDiskFlag.Name) {
+ cfg.EthashDatasetsOnDisk = ctx.GlobalInt(EthashDatasetsOnDiskFlag.Name)
+ }
+}
+
+func checkExclusive(ctx *cli.Context, flags ...cli.Flag) {
+ set := make([]string, 0, 1)
+ for _, flag := range flags {
+ if ctx.GlobalIsSet(flag.GetName()) {
+ set = append(set, "--"+flag.GetName())
}
}
- if networks > 1 {
- Fatalf("The %v flags are mutually exclusive", netFlags)
+ if len(set) > 1 {
+ Fatalf("flags %v can't be used at the same time", strings.Join(set, ", "))
}
+}
+
+// SetEthConfig applies eth-related command line flags to the config.
+func SetEthConfig(ctx *cli.Context, stack *node.Node, cfg *eth.Config) {
+ // Avoid conflicting network flags
+ checkExclusive(ctx, DevModeFlag, TestNetFlag)
+ checkExclusive(ctx, FastSyncFlag, LightModeFlag, SyncModeFlag)
+
ks := stack.AccountManager().Backends(keystore.KeyStoreType)[0].(*keystore.KeyStore)
+ setEtherbase(ctx, ks, cfg)
+ setGPO(ctx, &cfg.GPO)
+ setEthash(ctx, cfg)
+
+ switch {
+ case ctx.GlobalIsSet(SyncModeFlag.Name):
+ cfg.SyncMode = *GlobalTextMarshaler(ctx, SyncModeFlag.Name).(*downloader.SyncMode)
+ case ctx.GlobalBool(FastSyncFlag.Name):
+ cfg.SyncMode = downloader.FastSync
+ case ctx.GlobalBool(LightModeFlag.Name):
+ cfg.SyncMode = downloader.LightSync
+ }
+ if ctx.GlobalIsSet(LightServFlag.Name) {
+ cfg.LightServ = ctx.GlobalInt(LightServFlag.Name)
+ }
+ if ctx.GlobalIsSet(LightPeersFlag.Name) {
+ cfg.LightPeers = ctx.GlobalInt(LightPeersFlag.Name)
+ }
+ if ctx.GlobalIsSet(NetworkIdFlag.Name) {
+ cfg.NetworkId = ctx.GlobalInt(NetworkIdFlag.Name)
+ }
+
+ // Ethereum needs to know maxPeers to calculate the light server peer ratio.
+ // TODO(fjl): ensure Ethereum can get MaxPeers from node.
+ cfg.MaxPeers = ctx.GlobalInt(MaxPeersFlag.Name)
+
+ if ctx.GlobalIsSet(CacheFlag.Name) {
+ cfg.DatabaseCache = ctx.GlobalInt(CacheFlag.Name)
+ }
+ cfg.DatabaseHandles = makeDatabaseHandles()
+
+ if ctx.GlobalIsSet(MinerThreadsFlag.Name) {
+ cfg.MinerThreads = ctx.GlobalInt(MinerThreadsFlag.Name)
+ }
+ if ctx.GlobalIsSet(DocRootFlag.Name) {
+ cfg.DocRoot = ctx.GlobalString(DocRootFlag.Name)
+ }
+ if ctx.GlobalIsSet(ExtraDataFlag.Name) {
+ cfg.ExtraData = []byte(ctx.GlobalString(ExtraDataFlag.Name))
+ }
+ if ctx.GlobalIsSet(GasPriceFlag.Name) {
+ cfg.GasPrice = GlobalBig(ctx, GasPriceFlag.Name)
+ }
+
+ if ctx.GlobalIsSet(SolcPathFlag.Name) {
+ cfg.SolcPath = ctx.GlobalString(SolcPathFlag.Name)
+ }
+ if ctx.GlobalIsSet(VMEnableDebugFlag.Name) {
+ // TODO(fjl): force-enable this in --dev mode
+ cfg.EnablePreimageRecording = ctx.GlobalBool(VMEnableDebugFlag.Name)
+ }
- ethConf := &eth.Config{
- Etherbase: MakeEtherbase(ks, ctx),
- FastSync: ctx.GlobalBool(FastSyncFlag.Name),
- LightMode: ctx.GlobalBool(LightModeFlag.Name),
- LightServ: ctx.GlobalInt(LightServFlag.Name),
- LightPeers: ctx.GlobalInt(LightPeersFlag.Name),
- MaxPeers: ctx.GlobalInt(MaxPeersFlag.Name),
- DatabaseCache: ctx.GlobalInt(CacheFlag.Name),
- DatabaseHandles: MakeDatabaseHandles(),
- NetworkId: ctx.GlobalInt(NetworkIdFlag.Name),
- MinerThreads: ctx.GlobalInt(MinerThreadsFlag.Name),
- ExtraData: MakeMinerExtra(extra, ctx),
- DocRoot: ctx.GlobalString(DocRootFlag.Name),
- GasPrice: GlobalBig(ctx, GasPriceFlag.Name),
- GpoBlocks: ctx.GlobalInt(GpoBlocksFlag.Name),
- GpoPercentile: ctx.GlobalInt(GpoPercentileFlag.Name),
- SolcPath: ctx.GlobalString(SolcPathFlag.Name),
- EthashCacheDir: MakeEthashCacheDir(ctx),
- EthashCachesInMem: ctx.GlobalInt(EthashCachesInMemoryFlag.Name),
- EthashCachesOnDisk: ctx.GlobalInt(EthashCachesOnDiskFlag.Name),
- EthashDatasetDir: MakeEthashDatasetDir(ctx),
- EthashDatasetsInMem: ctx.GlobalInt(EthashDatasetsInMemoryFlag.Name),
- EthashDatasetsOnDisk: ctx.GlobalInt(EthashDatasetsOnDiskFlag.Name),
- EnablePreimageRecording: ctx.GlobalBool(VMEnableDebugFlag.Name),
- }
-
- // Override any default configs in dev mode or the test net
+ // Override any default configs for --dev and --testnet.
switch {
case ctx.GlobalBool(TestNetFlag.Name):
if !ctx.GlobalIsSet(NetworkIdFlag.Name) {
- ethConf.NetworkId = 3
+ cfg.NetworkId = 3
}
- ethConf.Genesis = core.DefaultTestnetGenesisBlock()
+ cfg.Genesis = core.DefaultTestnetGenesisBlock()
case ctx.GlobalBool(DevModeFlag.Name):
- ethConf.Genesis = core.DevGenesisBlock()
+ cfg.Genesis = core.DevGenesisBlock()
if !ctx.GlobalIsSet(GasPriceFlag.Name) {
- ethConf.GasPrice = new(big.Int)
+ cfg.GasPrice = new(big.Int)
}
- ethConf.PowTest = true
+ cfg.PowTest = true
}
- // Override any global options pertaining to the Ethereum protocol
+
+ // TODO(fjl): move trie cache generations into config
if gen := ctx.GlobalInt(TrieCacheGenFlag.Name); gen > 0 {
state.MaxTrieCacheGen = uint16(gen)
}
+}
- if ethConf.LightMode {
- if err := stack.Register(func(ctx *node.ServiceContext) (node.Service, error) {
- return les.New(ctx, ethConf)
- }); err != nil {
- Fatalf("Failed to register the Ethereum light node service: %v", err)
- }
+// RegisterEthService adds an Ethereum client to the stack.
+func RegisterEthService(stack *node.Node, cfg *eth.Config) {
+ var err error
+ if cfg.SyncMode == downloader.LightSync {
+ err = stack.Register(func(ctx *node.ServiceContext) (node.Service, error) {
+ return les.New(ctx, cfg)
+ })
} else {
- if err := stack.Register(func(ctx *node.ServiceContext) (node.Service, error) {
- fullNode, err := eth.New(ctx, ethConf)
- if fullNode != nil && ethConf.LightServ > 0 {
- ls, _ := les.NewLesServer(fullNode, ethConf)
+ err = stack.Register(func(ctx *node.ServiceContext) (node.Service, error) {
+ fullNode, err := eth.New(ctx, cfg)
+ if fullNode != nil && cfg.LightServ > 0 {
+ ls, _ := les.NewLesServer(fullNode, cfg)
fullNode.AddLesServer(ls)
}
return fullNode, err
- }); err != nil {
- Fatalf("Failed to register the Ethereum full node service: %v", err)
- }
+ })
+ }
+ if err != nil {
+ Fatalf("Failed to register the Ethereum service: %v", err)
}
}
@@ -855,6 +906,7 @@ func RegisterEthStatsService(stack *node.Node, url string) {
// SetupNetwork configures the system for either the main net or some test network.
func SetupNetwork(ctx *cli.Context) {
+ // TODO(fjl): move target gas limit into config
params.TargetGasLimit = new(big.Int).SetUint64(ctx.GlobalUint64(TargetGasLimitFlag.Name))
}
@@ -870,7 +922,7 @@ func ChainDbName(ctx *cli.Context) string {
func MakeChainDatabase(ctx *cli.Context, stack *node.Node) ethdb.Database {
var (
cache = ctx.GlobalInt(CacheFlag.Name)
- handles = MakeDatabaseHandles()
+ handles = makeDatabaseHandles()
name = ChainDbName(ctx)
)
diff --git a/cmd/wnode/main.go b/cmd/wnode/main.go
index 7431980b5..b40352f57 100644
--- a/cmd/wnode/main.go
+++ b/cmd/wnode/main.go
@@ -257,7 +257,6 @@ func initialize() {
Config: p2p.Config{
PrivateKey: nodeid,
MaxPeers: maxPeers,
- Discovery: true,
Name: common.MakeName("wnode", "5.0"),
Protocols: shh.Protocols(),
ListenAddr: *argIP,