aboutsummaryrefslogtreecommitdiffstats
path: root/cmd/geth
diff options
context:
space:
mode:
authorPéter Szilágyi <peterke@gmail.com>2017-06-26 18:44:35 +0800
committerGitHub <noreply@github.com>2017-06-26 18:44:35 +0800
commitfeb29327066d6076d1802cdc1492d43a39cec276 (patch)
tree93f3231648b0f225c0c8d44bf81304282f93b605 /cmd/geth
parentf321ed23fbaad8a13cc672f601b15f5272b4b2bb (diff)
parentea1d1825a8509b3353c535c9444861e15471942a (diff)
downloaddexon-feb29327066d6076d1802cdc1492d43a39cec276.tar.gz
dexon-feb29327066d6076d1802cdc1492d43a39cec276.tar.zst
dexon-feb29327066d6076d1802cdc1492d43a39cec276.zip
Merge pull request #14540 from bas-vk/whisper-api
whisperv5: integrate whisper and implement API
Diffstat (limited to 'cmd/geth')
-rw-r--r--cmd/geth/config.go33
-rw-r--r--cmd/geth/consolecmd.go2
-rw-r--r--cmd/geth/main.go8
-rw-r--r--cmd/geth/usage.go9
4 files changed, 40 insertions, 12 deletions
diff --git a/cmd/geth/config.go b/cmd/geth/config.go
index b76da3042..d3600f141 100644
--- a/cmd/geth/config.go
+++ b/cmd/geth/config.go
@@ -33,6 +33,7 @@ import (
"github.com/ethereum/go-ethereum/eth"
"github.com/ethereum/go-ethereum/node"
"github.com/ethereum/go-ethereum/params"
+ whisper "github.com/ethereum/go-ethereum/whisper/whisperv5"
"github.com/naoina/toml"
)
@@ -42,7 +43,7 @@ var (
Name: "dumpconfig",
Usage: "Show configuration values",
ArgsUsage: "",
- Flags: append(nodeFlags, rpcFlags...),
+ Flags: append(append(nodeFlags, rpcFlags...), whisperFlags...),
Category: "MISCELLANEOUS COMMANDS",
Description: `The dumpconfig command shows configuration values.`,
}
@@ -76,6 +77,7 @@ type ethstatsConfig struct {
type gethConfig struct {
Eth eth.Config
+ Shh whisper.Config
Node node.Config
Ethstats ethstatsConfig
}
@@ -99,8 +101,8 @@ 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.HTTPModules = append(cfg.HTTPModules, "eth", "shh")
+ cfg.WSModules = append(cfg.WSModules, "eth", "shh")
cfg.IPCPath = "geth.ipc"
return cfg
}
@@ -109,6 +111,7 @@ func makeConfigNode(ctx *cli.Context) (*node.Node, gethConfig) {
// Load defaults.
cfg := gethConfig{
Eth: eth.DefaultConfig,
+ Shh: whisper.DefaultConfig,
Node: defaultNodeConfig(),
}
@@ -130,19 +133,37 @@ func makeConfigNode(ctx *cli.Context) (*node.Node, gethConfig) {
cfg.Ethstats.URL = ctx.GlobalString(utils.EthStatsURLFlag.Name)
}
+ utils.SetShhConfig(ctx, stack, &cfg.Shh)
+
return stack, cfg
}
+// enableWhisper returns true in case one of the whisper flags is set.
+func enableWhisper(ctx *cli.Context) bool {
+ for _, flag := range whisperFlags {
+ if ctx.GlobalIsSet(flag.GetName()) {
+ return true
+ }
+ }
+ return false
+}
+
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)
+ // Whisper must be explicitly enabled by specifying at least 1 whisper flag or in dev mode
+ shhEnabled := enableWhisper(ctx)
shhAutoEnabled := !ctx.GlobalIsSet(utils.WhisperEnabledFlag.Name) && ctx.GlobalIsSet(utils.DevModeFlag.Name)
if shhEnabled || shhAutoEnabled {
- utils.RegisterShhService(stack)
+ if ctx.GlobalIsSet(utils.WhisperMaxMessageSizeFlag.Name) {
+ cfg.Shh.MaxMessageSize = uint32(ctx.Int(utils.WhisperMaxMessageSizeFlag.Name))
+ }
+ if ctx.GlobalIsSet(utils.WhisperMinPOWFlag.Name) {
+ cfg.Shh.MinimumAcceptedPOW = ctx.Float64(utils.WhisperMinPOWFlag.Name)
+ }
+ utils.RegisterShhService(stack, &cfg.Shh)
}
// Add the Ethereum Stats daemon if requested.
diff --git a/cmd/geth/consolecmd.go b/cmd/geth/consolecmd.go
index f8a923aac..2bb452d73 100644
--- a/cmd/geth/consolecmd.go
+++ b/cmd/geth/consolecmd.go
@@ -35,7 +35,7 @@ var (
Action: utils.MigrateFlags(localConsole),
Name: "console",
Usage: "Start an interactive JavaScript environment",
- Flags: append(append(nodeFlags, rpcFlags...), consoleFlags...),
+ Flags: append(append(append(nodeFlags, rpcFlags...), consoleFlags...), whisperFlags...),
Category: "CONSOLE COMMANDS",
Description: `
The Geth console is an interactive shell for the JavaScript runtime environment
diff --git a/cmd/geth/main.go b/cmd/geth/main.go
index b5cdd712d..7e0242d8f 100644
--- a/cmd/geth/main.go
+++ b/cmd/geth/main.go
@@ -95,7 +95,6 @@ var (
utils.NetrestrictFlag,
utils.NodeKeyFileFlag,
utils.NodeKeyHexFlag,
- utils.WhisperEnabledFlag,
utils.DevModeFlag,
utils.TestnetFlag,
utils.RinkebyFlag,
@@ -125,6 +124,12 @@ var (
utils.IPCDisabledFlag,
utils.IPCPathFlag,
}
+
+ whisperFlags = []cli.Flag{
+ utils.WhisperEnabledFlag,
+ utils.WhisperMaxMessageSizeFlag,
+ utils.WhisperMinPOWFlag,
+ }
)
func init() {
@@ -161,6 +166,7 @@ func init() {
app.Flags = append(app.Flags, rpcFlags...)
app.Flags = append(app.Flags, consoleFlags...)
app.Flags = append(app.Flags, debug.Flags...)
+ app.Flags = append(app.Flags, whisperFlags...)
app.Before = func(ctx *cli.Context) error {
runtime.GOMAXPROCS(runtime.NumCPU())
diff --git a/cmd/geth/usage.go b/cmd/geth/usage.go
index 2ba504fdd..022c8e899 100644
--- a/cmd/geth/usage.go
+++ b/cmd/geth/usage.go
@@ -188,6 +188,10 @@ var AppHelpFlagGroups = []flagGroup{
}, debug.Flags...),
},
{
+ Name: "WHISPER (EXPERIMENTAL)",
+ Flags: whisperFlags,
+ },
+ {
Name: "DEPRECATED",
Flags: []cli.Flag{
utils.FastSyncFlag,
@@ -195,10 +199,7 @@ var AppHelpFlagGroups = []flagGroup{
},
},
{
- Name: "EXPERIMENTAL",
- Flags: []cli.Flag{
- utils.WhisperEnabledFlag,
- },
+ Name: "MISC",
},
}