From b58a5016738b92db19e08ec87ef34ce3250fae6b Mon Sep 17 00:00:00 2001 From: Bas van Kervel Date: Tue, 13 Jun 2017 11:49:07 +0200 Subject: whisperv5: integrate whisper and add whisper RPC simulator --- cmd/utils/flags.go | 21 ++++++++++++++------- 1 file changed, 14 insertions(+), 7 deletions(-) (limited to 'cmd/utils') diff --git a/cmd/utils/flags.go b/cmd/utils/flags.go index 3c97cd3bb..095a9f62c 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", @@ -878,6 +873,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(whisper.MaxMessageSizeFlag.Name) { + cfg.MaxMessageSize = uint32(ctx.GlobalUint(whisper.MaxMessageSizeFlag.Name)) + } + if ctx.GlobalIsSet(whisper.MinPOWFlag.Name) { + cfg.MinimumAcceptedPOW = ctx.GlobalFloat64(whisper.MinPOWFlag.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 +988,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) } } -- cgit