Skip to content

Commit 749037a

Browse files
committed
whisper: remove whisper (ethereum#21487)
1 parent 9a5fb2a commit 749037a

29 files changed

+13
-7846
lines changed

cmd/XDC/config.go

Lines changed: 5 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,6 @@ import (
3737
"github.com/XinFinOrg/XDPoSChain/log"
3838
"github.com/XinFinOrg/XDPoSChain/node"
3939
"github.com/XinFinOrg/XDPoSChain/params"
40-
whisper "github.com/XinFinOrg/XDPoSChain/whisper/whisperv6"
4140
"github.com/naoina/toml"
4241
)
4342

@@ -91,7 +90,6 @@ type Bootnodes struct {
9190

9291
type XDCConfig struct {
9392
Eth ethconfig.Config
94-
Shh whisper.Config
9593
Node node.Config
9694
Ethstats ethstatsConfig
9795
XDCX XDCx.Config
@@ -130,7 +128,6 @@ func makeConfigNode(ctx *cli.Context) (*node.Node, XDCConfig) {
130128
// Load defaults.
131129
cfg := XDCConfig{
132130
Eth: ethconfig.Defaults,
133-
Shh: whisper.DefaultConfig,
134131
XDCX: XDCx.DefaultConfig,
135132
Node: defaultNodeConfig(),
136133
StakeEnable: true,
@@ -212,7 +209,7 @@ func makeConfigNode(ctx *cli.Context) (*node.Node, XDCConfig) {
212209
cfg.Ethstats.URL = ctx.GlobalString(utils.EthStatsURLFlag.Name)
213210
}
214211

215-
utils.SetShhConfig(ctx, stack, &cfg.Shh)
212+
utils.SetShhConfig(ctx, stack)
216213
utils.SetXDCXConfig(ctx, &cfg.XDCX, cfg.Node.DataDir)
217214
return stack, cfg
218215
}
@@ -230,14 +227,13 @@ func applyValues(values []string, params *[]string) {
230227

231228
}
232229

233-
// enableWhisper returns true in case one of the whisper flags is set.
234-
func enableWhisper(ctx *cli.Context) bool {
230+
// checkWhisper returns true in case one of the whisper flags is set.
231+
func checkWhisper(ctx *cli.Context) {
235232
for _, flag := range whisperFlags {
236233
if ctx.GlobalIsSet(flag.GetName()) {
237-
return true
234+
log.Warn("deprecated whisper flag detected. Whisper has been moved to github.com/ethereum/whisper")
238235
}
239236
}
240-
return false
241237
}
242238

243239
func makeFullNode(ctx *cli.Context) (*node.Node, XDCConfig) {
@@ -248,19 +244,7 @@ func makeFullNode(ctx *cli.Context) (*node.Node, XDCConfig) {
248244
utils.RegisterXDCXService(stack, &cfg.XDCX)
249245
utils.RegisterEthService(stack, &cfg.Eth)
250246

251-
// Whisper must be explicitly enabled by specifying at least 1 whisper flag or in dev mode
252-
shhEnabled := enableWhisper(ctx)
253-
shhAutoEnabled := !ctx.GlobalIsSet(utils.WhisperEnabledFlag.Name) && ctx.GlobalIsSet(utils.DeveloperFlag.Name)
254-
if shhEnabled || shhAutoEnabled {
255-
if ctx.GlobalIsSet(utils.WhisperMaxMessageSizeFlag.Name) {
256-
cfg.Shh.MaxMessageSize = uint32(ctx.Int(utils.WhisperMaxMessageSizeFlag.Name))
257-
}
258-
if ctx.GlobalIsSet(utils.WhisperMinPOWFlag.Name) {
259-
cfg.Shh.MinimumAcceptedPOW = ctx.Float64(utils.WhisperMinPOWFlag.Name)
260-
}
261-
utils.RegisterShhService(stack, &cfg.Shh)
262-
}
263-
247+
checkWhisper(ctx)
264248
// Add the Ethereum Stats daemon if requested.
265249
if cfg.Ethstats.URL != "" {
266250
utils.RegisterEthStatsService(stack, cfg.Ethstats.URL)

cmd/XDC/usage.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -218,7 +218,7 @@ var AppHelpFlagGroups = []flagGroup{
218218
}, debug.Flags...),
219219
},
220220
//{
221-
// Name: "WHISPER (EXPERIMENTAL)",
221+
// Name: "WHISPER (deprecated)",
222222
// Flags: whisperFlags,
223223
//},
224224
{

cmd/utils/flags.go

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,6 @@ import (
5858
"github.com/XinFinOrg/XDPoSChain/p2p/netutil"
5959
"github.com/XinFinOrg/XDPoSChain/params"
6060
"github.com/XinFinOrg/XDPoSChain/rpc"
61-
whisper "github.com/XinFinOrg/XDPoSChain/whisper/whisperv6"
6261
gopsutil "github.com/shirou/gopsutil/mem"
6362
"gopkg.in/urfave/cli.v1"
6463
)
@@ -598,12 +597,12 @@ var (
598597
WhisperMaxMessageSizeFlag = cli.IntFlag{
599598
Name: "shh.maxmessagesize",
600599
Usage: "Max message size accepted",
601-
Value: int(whisper.DefaultMaxMessageSize),
600+
Value: 1024 * 1024,
602601
}
603602
WhisperMinPOWFlag = cli.Float64Flag{
604603
Name: "shh.pow",
605604
Usage: "Minimum POW accepted",
606-
Value: whisper.DefaultMinimumPoW,
605+
Value: 0.2,
607606
}
608607
XDCXDataDirFlag = DirectoryFlag{
609608
Name: "XDCx.datadir",
@@ -1145,12 +1144,11 @@ func checkExclusive(ctx *cli.Context, args ...interface{}) {
11451144
}
11461145

11471146
// SetShhConfig applies shh-related command line flags to the config.
1148-
func SetShhConfig(ctx *cli.Context, stack *node.Node, cfg *whisper.Config) {
1149-
if ctx.GlobalIsSet(WhisperMaxMessageSizeFlag.Name) {
1150-
cfg.MaxMessageSize = uint32(ctx.GlobalUint(WhisperMaxMessageSizeFlag.Name))
1151-
}
1152-
if ctx.GlobalIsSet(WhisperMinPOWFlag.Name) {
1153-
cfg.MinimumAcceptedPOW = ctx.GlobalFloat64(WhisperMinPOWFlag.Name)
1147+
func SetShhConfig(ctx *cli.Context, stack *node.Node) {
1148+
if ctx.GlobalIsSet(WhisperEnabledFlag.Name) ||
1149+
ctx.GlobalIsSet(WhisperMaxMessageSizeFlag.Name) ||
1150+
ctx.GlobalIsSet(WhisperMinPOWFlag.Name) {
1151+
log.Warn("Whisper support has been deprecated and the code has been moved to github.com/ethereum/whisper")
11541152
}
11551153
}
11561154

cmd/utils/utils.go

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@ import (
99
"github.com/XinFinOrg/XDPoSChain/ethstats"
1010
"github.com/XinFinOrg/XDPoSChain/les"
1111
"github.com/XinFinOrg/XDPoSChain/node"
12-
whisper "github.com/XinFinOrg/XDPoSChain/whisper/whisperv6"
1312
)
1413

1514
// RegisterEthService adds an Ethereum client to the stack.
@@ -38,15 +37,6 @@ func RegisterEthService(stack *node.Node, cfg *ethconfig.Config) {
3837
}
3938
}
4039

41-
// RegisterShhService configures Whisper and adds it to the given node.
42-
func RegisterShhService(stack *node.Node, cfg *whisper.Config) {
43-
if err := stack.Register(func(n *node.ServiceContext) (node.Service, error) {
44-
return whisper.New(cfg), nil
45-
}); err != nil {
46-
Fatalf("Failed to register the Whisper service: %v", err)
47-
}
48-
}
49-
5040
// RegisterEthStatsService configures the Ethereum Stats daemon and adds it to the node.
5141
func RegisterEthStatsService(stack *node.Node, url string) {
5242
if err := stack.Register(func(ctx *node.ServiceContext) (node.Service, error) {

0 commit comments

Comments
 (0)