Skip to content

Commit

Permalink
whisper: remove whisper
Browse files Browse the repository at this point in the history
  • Loading branch information
JukLee0ira committed Oct 24, 2024
1 parent 22c5420 commit 2fcb1da
Show file tree
Hide file tree
Showing 29 changed files with 13 additions and 7,871 deletions.
26 changes: 5 additions & 21 deletions cmd/XDC/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,6 @@ import (
"github.com/XinFinOrg/XDPoSChain/log"
"github.com/XinFinOrg/XDPoSChain/node"
"github.com/XinFinOrg/XDPoSChain/params"
whisper "github.com/XinFinOrg/XDPoSChain/whisper/whisperv6"
"github.com/naoina/toml"
)

Expand Down Expand Up @@ -91,7 +90,6 @@ type Bootnodes struct {

type XDCConfig struct {
Eth ethconfig.Config
Shh whisper.Config
Node node.Config
Ethstats ethstatsConfig
XDCX XDCx.Config
Expand Down Expand Up @@ -130,7 +128,6 @@ func makeConfigNode(ctx *cli.Context) (*node.Node, XDCConfig) {
// Load defaults.
cfg := XDCConfig{
Eth: ethconfig.Defaults,
Shh: whisper.DefaultConfig,
XDCX: XDCx.DefaultConfig,
Node: defaultNodeConfig(),
StakeEnable: true,
Expand Down Expand Up @@ -212,7 +209,7 @@ func makeConfigNode(ctx *cli.Context) (*node.Node, XDCConfig) {
cfg.Ethstats.URL = ctx.GlobalString(utils.EthStatsURLFlag.Name)
}

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

}

// enableWhisper returns true in case one of the whisper flags is set.
func enableWhisper(ctx *cli.Context) bool {
// checkWhisper returns true in case one of the whisper flags is set.
func checkWhisper(ctx *cli.Context) {
for _, flag := range whisperFlags {
if ctx.GlobalIsSet(flag.GetName()) {
return true
log.Warn("deprecated whisper flag detected. Whisper has been moved to github.com/ethereum/whisper")
}
}
return false
}

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

// 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.DeveloperFlag.Name)
if shhEnabled || shhAutoEnabled {
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)
}

checkWhisper(ctx)
// Add the Ethereum Stats daemon if requested.
if cfg.Ethstats.URL != "" {
utils.RegisterEthStatsService(stack, cfg.Ethstats.URL)
Expand Down
2 changes: 1 addition & 1 deletion cmd/XDC/usage.go
Original file line number Diff line number Diff line change
Expand Up @@ -216,7 +216,7 @@ var AppHelpFlagGroups = []flagGroup{
}, debug.Flags...),
},
//{
// Name: "WHISPER (EXPERIMENTAL)",
// Name: "WHISPER (deprecated)",
// Flags: whisperFlags,
//},
{
Expand Down
16 changes: 7 additions & 9 deletions cmd/utils/flags.go
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,6 @@ import (
"github.com/XinFinOrg/XDPoSChain/p2p/netutil"
"github.com/XinFinOrg/XDPoSChain/params"
"github.com/XinFinOrg/XDPoSChain/rpc"
whisper "github.com/XinFinOrg/XDPoSChain/whisper/whisperv6"
gopsutil "github.com/shirou/gopsutil/mem"
"gopkg.in/urfave/cli.v1"
)
Expand Down Expand Up @@ -587,12 +586,12 @@ var (
WhisperMaxMessageSizeFlag = cli.IntFlag{
Name: "shh.maxmessagesize",
Usage: "Max message size accepted",
Value: int(whisper.DefaultMaxMessageSize),
Value: 1024 * 1024,
}
WhisperMinPOWFlag = cli.Float64Flag{
Name: "shh.pow",
Usage: "Minimum POW accepted",
Value: whisper.DefaultMinimumPoW,
Value: 0.2,
}
XDCXDataDirFlag = DirectoryFlag{
Name: "XDCx.datadir",
Expand Down Expand Up @@ -1126,12 +1125,11 @@ func checkExclusive(ctx *cli.Context, args ...interface{}) {
}

// 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)
func SetShhConfig(ctx *cli.Context, stack *node.Node) {
if ctx.GlobalIsSet(WhisperEnabledFlag.Name) ||
ctx.GlobalIsSet(WhisperMaxMessageSizeFlag.Name) ||
ctx.GlobalIsSet(WhisperMinPOWFlag.Name) {
log.Warn("Whisper support has been deprecated and the code has been moved to github.com/ethereum/whisper")
}
}

Expand Down
10 changes: 0 additions & 10 deletions cmd/utils/utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ import (
"github.com/XinFinOrg/XDPoSChain/ethstats"
"github.com/XinFinOrg/XDPoSChain/les"
"github.com/XinFinOrg/XDPoSChain/node"
whisper "github.com/XinFinOrg/XDPoSChain/whisper/whisperv6"
)

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

// RegisterShhService configures Whisper and adds it to the given node.
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)
}
}

// RegisterEthStatsService configures the Ethereum Stats daemon and adds it to the node.
func RegisterEthStatsService(stack *node.Node, url string) {
if err := stack.Register(func(ctx *node.ServiceContext) (node.Service, error) {
Expand Down
Loading

0 comments on commit 2fcb1da

Please sign in to comment.