From 8eb5fa7666b6d41e2eca3d052e719e2783a113d9 Mon Sep 17 00:00:00 2001 From: Daniel Liu <139250065@qq.com> Date: Mon, 8 Dec 2025 15:23:05 +0800 Subject: [PATCH] cmd: remove slave mode and flag XDCSlaveModeFlag (#1824) --- cmd/XDC/main.go | 68 +++++++++++++++++++--------------------------- cmd/utils/flags.go | 5 ---- 2 files changed, 28 insertions(+), 45 deletions(-) diff --git a/cmd/XDC/main.go b/cmd/XDC/main.go index 19d30d5dc8..9a5ef531bd 100644 --- a/cmd/XDC/main.go +++ b/cmd/XDC/main.go @@ -139,7 +139,6 @@ var ( utils.StoreRewardFlag, utils.SetHeadFlag, utils.DeleteAllBadBlocksFlag, - utils.XDCSlaveModeFlag, }, utils.NetworkFlags, utils.DatabaseFlags) rpcFlags = []cli.Flag{ @@ -346,35 +345,29 @@ func startNode(ctx *cli.Context, stack *node.Node, backend ethapi.Backend, cfg X go func() { started := false ok := false - slaveMode := ctx.IsSet(utils.XDCSlaveModeFlag.Name) var err error ok, err = ethBackend.ValidateMasternode() if err != nil { utils.Fatalf("Can't verify masternode permission: %v", err) } if ok { - if slaveMode { - log.Info("Masternode slave mode found.") - started = false - } else { - log.Info("Masternode found. Enabling staking mode...") - // Use a reduced number of threads if requested - if threads := ctx.Int(utils.MinerThreadsFlag.Name); threads > 0 { - type threaded interface { - SetThreads(threads int) - } - if th, ok := ethBackend.Engine().(threaded); ok { - th.SetThreads(threads) - } + log.Info("Masternode found. Enabling staking mode...") + // Use a reduced number of threads if requested + if threads := ctx.Int(utils.MinerThreadsFlag.Name); threads > 0 { + type threaded interface { + SetThreads(threads int) } - // Set the gas price to the limits from the CLI and start mining - ethBackend.TxPool().SetGasPrice(cfg.Eth.GasPrice) - if err := ethBackend.StartStaking(true); err != nil { - utils.Fatalf("Failed to start staking: %v", err) + if th, ok := ethBackend.Engine().(threaded); ok { + th.SetThreads(threads) } - started = true - log.Info("Enabled staking node!!!") } + // Set the gas price to the limits from the CLI and start mining + ethBackend.TxPool().SetGasPrice(cfg.Eth.GasPrice) + if err := ethBackend.StartStaking(true); err != nil { + utils.Fatalf("Failed to start staking: %v", err) + } + started = true + log.Info("Enabled staking node!!!") } defer close(core.CheckpointCh) for range core.CheckpointCh { @@ -395,28 +388,23 @@ func startNode(ctx *cli.Context, stack *node.Node, backend ethapi.Backend, cfg X log.Info("Cancelled mining mode!!!") } } else if !started { - if slaveMode { - log.Info("Masternode slave mode found.") - started = false - } else { - log.Info("Masternode found. Enabling staking mode...") - // Use a reduced number of threads if requested - if threads := ctx.Int(utils.MinerThreadsFlag.Name); threads > 0 { - type threaded interface { - SetThreads(threads int) - } - if th, ok := ethBackend.Engine().(threaded); ok { - th.SetThreads(threads) - } + log.Info("Masternode found. Enabling staking mode...") + // Use a reduced number of threads if requested + if threads := ctx.Int(utils.MinerThreadsFlag.Name); threads > 0 { + type threaded interface { + SetThreads(threads int) } - // Set the gas price to the limits from the CLI and start mining - ethBackend.TxPool().SetGasPrice(cfg.Eth.GasPrice) - if err := ethBackend.StartStaking(true); err != nil { - utils.Fatalf("Failed to start staking: %v", err) + if th, ok := ethBackend.Engine().(threaded); ok { + th.SetThreads(threads) } - started = true - log.Info("Enabled staking node!!!") } + // Set the gas price to the limits from the CLI and start mining + ethBackend.TxPool().SetGasPrice(cfg.Eth.GasPrice) + if err := ethBackend.StartStaking(true); err != nil { + utils.Fatalf("Failed to start staking: %v", err) + } + started = true + log.Info("Enabled staking node!!!") } } }() diff --git a/cmd/utils/flags.go b/cmd/utils/flags.go index c7d9215554..7fac04a4a6 100644 --- a/cmd/utils/flags.go +++ b/cmd/utils/flags.go @@ -837,11 +837,6 @@ var ( Value: false, Category: flags.XdcCategory, } - XDCSlaveModeFlag = &cli.BoolFlag{ - Name: "slave", - Usage: "Enable slave mode", - Category: flags.XdcCategory, - } // XDCX settings XDCXDBNameFlag = &cli.StringFlag{