aboutsummaryrefslogtreecommitdiffstats
path: root/cmd/utils/flags.go
diff options
context:
space:
mode:
Diffstat (limited to 'cmd/utils/flags.go')
-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)
}
}