aboutsummaryrefslogtreecommitdiffstats
path: root/cmd/utils
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/utils
parentf321ed23fbaad8a13cc672f601b15f5272b4b2bb (diff)
parentea1d1825a8509b3353c535c9444861e15471942a (diff)
downloaddexon-feb29327066d6076d1802cdc1492d43a39cec276.tar
dexon-feb29327066d6076d1802cdc1492d43a39cec276.tar.gz
dexon-feb29327066d6076d1802cdc1492d43a39cec276.tar.bz2
dexon-feb29327066d6076d1802cdc1492d43a39cec276.tar.lz
dexon-feb29327066d6076d1802cdc1492d43a39cec276.tar.xz
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/utils')
-rw-r--r--cmd/utils/flags.go35
1 files changed, 28 insertions, 7 deletions
diff --git a/cmd/utils/flags.go b/cmd/utils/flags.go
index 3c97cd3bb..b5a593ab6 100644
--- a/cmd/utils/flags.go
+++ b/cmd/utils/flags.go
@@ -440,11 +440,6 @@ var (
Usage: "Restricts network communication to the given IP networks (CIDR masks)",
}
- WhisperEnabledFlag = cli.BoolFlag{
- Name: "shh",
- Usage: "Enable Whisper",
- }
-
// ATM the url is left to the user and deployment to
JSpathFlag = cli.StringFlag{
Name: "jspath",
@@ -463,6 +458,20 @@ var (
Usage: "Suggested gas price is the given percentile of a set of recent transaction gas prices",
Value: eth.DefaultConfig.GPO.Percentile,
}
+ WhisperEnabledFlag = cli.BoolFlag{
+ Name: "shh",
+ Usage: "Enable Whisper",
+ }
+ WhisperMaxMessageSizeFlag = cli.IntFlag{
+ Name: "shh.maxmessagesize",
+ Usage: "Max message size accepted",
+ Value: int(whisper.DefaultMaxMessageSize),
+ }
+ WhisperMinPOWFlag = cli.Float64Flag{
+ Name: "shh.pow",
+ Usage: "Minimum POW accepted",
+ Value: whisper.DefaultMinimumPoW,
+ }
)
// MakeDataDir retrieves the currently requested data directory, terminating
@@ -878,6 +887,16 @@ func checkExclusive(ctx *cli.Context, flags ...cli.Flag) {
}
}
+// SetShhConfig applies shh-related command line flags to the config.
+func SetShhConfig(ctx *cli.Context, stack *node.Node, cfg *whisper.Config) {
+ if ctx.GlobalIsSet(WhisperMaxMessageSizeFlag.Name) {
+ cfg.MaxMessageSize = uint32(ctx.GlobalUint(WhisperMaxMessageSizeFlag.Name))
+ }
+ if ctx.GlobalIsSet(WhisperMinPOWFlag.Name) {
+ cfg.MinimumAcceptedPOW = ctx.GlobalFloat64(WhisperMinPOWFlag.Name)
+ }
+}
+
// 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
@@ -983,8 +1002,10 @@ func RegisterEthService(stack *node.Node, cfg *eth.Config) {
}
// RegisterShhService configures Whisper and adds it to the given node.
-func RegisterShhService(stack *node.Node) {
- if err := stack.Register(func(*node.ServiceContext) (node.Service, error) { return whisper.New(), nil }); err != nil {
+func RegisterShhService(stack *node.Node, cfg *whisper.Config) {
+ if err := stack.Register(func(n *node.ServiceContext) (node.Service, error) {
+ return whisper.New(cfg), nil
+ }); err != nil {
Fatalf("Failed to register the Whisper service: %v", err)
}
}